From 1c7d5e8e5145f6499aee588f841d1653103086ad Mon Sep 17 00:00:00 2001 From: xiaosi <2652281683@qq.com> Date: Thu, 3 Sep 2026 10:21:08 +0800 Subject: [PATCH] fix: close confirm dialog when clicking cancel Custom DialogPlugin onClose replaced the default hide path, so Cancel resolved false but left the modal open. Hide on cancel/close and settle once. --- src/stores/modules/uiStore.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/stores/modules/uiStore.js b/src/stores/modules/uiStore.js index 3b31f28..3011f47 100644 --- a/src/stores/modules/uiStore.js +++ b/src/stores/modules/uiStore.js @@ -13,6 +13,13 @@ export const useUiStore = defineStore('ui', () => { checks = ['设备在线', '无活动告警', '指令互斥检查'] ) { return new Promise((resolve) => { + let settled = false + const settle = (value) => { + if (settled) return + settled = true + resolve(value) + } + const list = Array.isArray(checks) ? checks.filter(Boolean) : [] const body = list.length ? () => @@ -32,18 +39,23 @@ export const useUiStore = defineStore('ui', () => { confirmBtn: '确认执行', cancelBtn: '取消', theme: 'warning', + destroyOnClose: true, onConfirm: () => { dialog.hide() - resolve(true) + settle(true) }, + // 自定义 onClose 会覆盖插件默认关窗;取消/关闭都必须自行 hide onClose: () => { - resolve(false) + dialog.hide() + settle(false) }, onCloseBtnClick: () => { - resolve(false) + dialog.hide() + settle(false) }, onCancel: () => { - resolve(false) + dialog.hide() + settle(false) }, }) })