From 136bc0ecd58909e31dd21d5d67bcb4bdb0d7044f Mon Sep 17 00:00:00 2001 From: Hayden <48267247+hayden-fr@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:03:46 +0800 Subject: [PATCH] feat(dialog): Optimize dialog closing logic (#97) - Add optional parameters to the close function to support parameterless calling - When the dialog parameter is not provided, automatically close the dialog box on the top of the stack --- src/hooks/dialog.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hooks/dialog.ts b/src/hooks/dialog.ts index 4fc1ee3..2c53c60 100644 --- a/src/hooks/dialog.ts +++ b/src/hooks/dialog.ts @@ -49,7 +49,12 @@ export const useDialog = defineStore('dialog', () => { } } - const close = (dialog: { key: string }) => { + const close = (dialog?: { key: string }) => { + if (!dialog) { + stack.value.pop() + return + } + const item = stack.value.find((item) => item.key === dialog.key) if (item?.keepAlive) { item.visible = false