From f74fe1114520ea0f999da51316ad82f433bec43e Mon Sep 17 00:00:00 2001 From: lanrtop Date: Wed, 30 Sep 2026 13:48:54 +0900 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E7=A1=AE=E8=AE=A4=E6=A1=86=E5=9C=A8?= =?UTF-8?q?=20Tauri=20=E4=B8=8B=E8=A2=AB=E7=BB=95=E8=BF=87=E2=80=94?= =?UTF-8?q?=E2=80=94=E6=94=B9=E7=94=A8=20await=20plugin-dialog=20confirm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tauri-plugin-dialog 把 window.confirm 替换为 async 函数,同步判断拿到恒为真的 Promise,撤销测试账户、删除 Gitea 实例/解绑仓库、删除仓库、准备工具链 5 处 破坏性或改机器状态的操作均未弹框即执行(UI 终验发现)。统一 await @tauri-apps/plugin-dialog 的 confirm,并加源码扫描回归测试防复发。 Co-Authored-By: Claude Opus 5.5 --- src/components/dashboard/GiteaPanel.tsx | 5 ++-- .../dashboard/ProjectDevVariablesPanel.tsx | 5 ++-- src/components/dashboard/ProjectEnvModal.tsx | 4 ++- .../dashboard/RepoRegistryModal.tsx | 3 ++- src/lib/confirmUsage.test.ts | 26 +++++++++++++++++++ 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 src/lib/confirmUsage.test.ts diff --git a/src/components/dashboard/GiteaPanel.tsx b/src/components/dashboard/GiteaPanel.tsx index 0d88be9..d64070e 100644 --- a/src/components/dashboard/GiteaPanel.tsx +++ b/src/components/dashboard/GiteaPanel.tsx @@ -24,6 +24,7 @@ import { gitPush, type GiteaInstance, } from "../../lib/commands"; +import { confirm } from "@tauri-apps/plugin-dialog"; import { useUIStore } from "../../store/ui"; type BindMode = "create" | "migrate" | "link"; @@ -98,7 +99,7 @@ export function GiteaInstancesSection() { }; const handleDelete = async (inst: GiteaInstance) => { - if (!confirm(`删除实例「${inst.name}」?其下所有项目绑定会一并删除。`)) return; + if (!(await confirm(`删除实例「${inst.name}」?其下所有项目绑定会一并删除。`, { kind: "warning" }))) return; try { await giteaDeleteInstance(inst.id); qc.invalidateQueries({ queryKey: ["gitea-instances"] }); @@ -308,7 +309,7 @@ export function GiteaPanel({ projectId, projectName, projectPath }: Props) { }; const handleUnlink = async () => { - if (!confirm("解绑当前项目与 Gitea 仓库?(Gitea 侧仓库不会删除)")) return; + if (!(await confirm("解绑当前项目与 Gitea 仓库?(Gitea 侧仓库不会删除)", { kind: "warning" }))) return; try { await giteaUnlinkRepo(projectId); refresh(); diff --git a/src/components/dashboard/ProjectDevVariablesPanel.tsx b/src/components/dashboard/ProjectDevVariablesPanel.tsx index 0dacf0d..71898b5 100644 --- a/src/components/dashboard/ProjectDevVariablesPanel.tsx +++ b/src/components/dashboard/ProjectDevVariablesPanel.tsx @@ -6,6 +6,7 @@ import { saveProjectTestAccount, revokeProjectDevVariable, } from "../../lib/commands"; +import { confirm } from "@tauri-apps/plugin-dialog"; import { useUIStore } from "../../store/ui"; import { Dialog } from "../ui/Dialog"; @@ -142,8 +143,8 @@ export function ProjectDevVariablesPanel({ projectId, projectName, onClose }: Pr {item.configured && (