From 3dfed3a2df31bd419046a96ed34ef7cd2af6ce68 Mon Sep 17 00:00:00 2001 From: zhangshun <453905631@qq.com> Date: Mon, 1 Jun 2026 09:40:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=A8=A1=E5=9E=8B=E5=BA=93?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=A1=86=E8=B0=83=E7=94=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/ui/dialogs.ts | 29 +++++++++++++++++++++-------- web/src/vendor/w2ui.ts | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/web/src/ui/dialogs.ts b/web/src/ui/dialogs.ts index a9b00a8..896202e 100644 --- a/web/src/ui/dialogs.ts +++ b/web/src/ui/dialogs.ts @@ -1,4 +1,4 @@ -import { w2confirm, w2popup, w2utils } from "../vendor/w2ui"; +import { w2popup, w2utils } from "../vendor/w2ui"; type PopupActionEvent = { detail: { @@ -23,14 +23,27 @@ export function notifyError(error: unknown) { export function confirmDialog(message: string, title = "确认") { return new Promise((resolve) => { - w2confirm({ - msg: message, + let settled = false; + const settle = (value: boolean) => { + if (settled) return; + settled = true; + resolve(value); + }; + + w2utils.confirm({ + box: "body", title, - yes: "确定", - no: "取消" - }, undefined, (action: string) => { - resolve(action === "yes" || action === "Yes"); - }); + text: message, + btn_yes: { + text: "确定" + }, + btn_no: { + text: "取消" + } + }) + .yes(() => settle(true)) + .no(() => settle(false)) + .close(() => settle(false)); }); } diff --git a/web/src/vendor/w2ui.ts b/web/src/vendor/w2ui.ts index e183a64..5021054 100644 --- a/web/src/vendor/w2ui.ts +++ b/web/src/vendor/w2ui.ts @@ -28,6 +28,29 @@ type W2Utils = { title?: string; text?: string; }): unknown; + confirm(options: { + box?: string | HTMLElement; + title?: string; + text?: string; + btn_yes?: { + text?: string; + class?: string; + style?: string; + attrs?: string; + }; + btn_no?: { + text?: string; + class?: string; + style?: string; + attrs?: string; + }; + }): W2ConfirmPromise; +}; + +type W2ConfirmPromise = { + yes(callback: (event: unknown) => void): W2ConfirmPromise; + no(callback: (event: unknown) => void): W2ConfirmPromise; + close(callback: (event: unknown) => void): W2ConfirmPromise; }; type W2LayoutOptions = {