From d81d5f9ac78e9a8c97d0ca41c0e2bd42f60bd03b Mon Sep 17 00:00:00 2001 From: Jin Yi Date: Thu, 27 Nov 2025 22:04:24 +0900 Subject: [PATCH] refactor: dialog logic --- src/stores/dialogStore.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/stores/dialogStore.ts b/src/stores/dialogStore.ts index 333af1a0b7..b85a2ec6aa 100644 --- a/src/stores/dialogStore.ts +++ b/src/stores/dialogStore.ts @@ -215,12 +215,19 @@ export const useDialogStore = defineStore('dialog', () => { F extends Component = Component >(options: ShowDialogOptions) { const dialogKey = options.key || genDialogKey() - - let dialog = dialogStack.value.find((d) => d.key === dialogKey) - + const existingIndex = dialogStack.value.findIndex( + (d) => d.key === dialogKey + ) + let dialog = + existingIndex !== -1 ? dialogStack.value[existingIndex] : undefined if (dialog) { - dialog.visible = true - riseDialog(dialog) + if (!dialog.visible) { + dialogStack.value.splice(existingIndex, 1) + dialog = createDialog({ ...options, key: dialogKey }) + } else { + dialog.visible = true + riseDialog(dialog) + } } else { dialog = createDialog({ ...options, key: dialogKey }) }