feat: 添加全局确认对话框管理器,重构对话框服务,优化用户交互体验

This commit is contained in:
zhanggy committed 2025-10-28 16:34:42 +08:00
1 parent 4367fd6ed1
commit 562e4f5b9e
9 files changed
+543 -11

No files matched your search

+28 -7
View File
@@ -141,6 +141,7 @@ import { useRouter } from 'vue-router'
import { useTemplateStore } from '@/renderer/store/template'
import { Template } from '@/renderer/store/template'
import TemplateTree from '@/renderer/components/TemplateTree.vue'
import { ConfirmDialogService } from '@/renderer/utils/confirm-dialog-service'
const router = useRouter()
const templateStore = useTemplateStore()
@@ -216,8 +217,16 @@ const editTemplate = (template: Template) => {
router.push(`/create-template/${template.id}`)
}
const deleteTemplate = (template: Template) => {
if (confirm(`确定要删除模板 "${template.name}" 吗?此操作不可撤销。`)) {
const deleteTemplate = async (template: Template) => {
const confirmed = await ConfirmDialogService.confirm({
title: '删除模板',
message: `确定要删除模板 "${template.name}" 吗?此操作不可撤销。`,
confirmText: '删除',
cancelText: '取消',
confirmColor: 'error'
})
if (confirmed) {
storeDeleteTemplate(template.id)
}
}
@@ -249,16 +258,28 @@ const confirmExecuteTemplate = () => {
executePath.value,
dirNames
)
.then((result: any) => {
.then(async (result: any) => {
if (result.success) {
alert('模板执行成功!')
await ConfirmDialogService.success({
title: '执行成功',
message: '模板执行成功!',
confirmText: '确定'
})
showExecuteDialog.value = false
} else {
alert(`模板执行失败: ${result.error}`)
await ConfirmDialogService.error({
title: '执行失败',
message: `模板执行失败: ${result.error}`,
confirmText: '确定'
})
}
})
.catch((error: any) => {
alert(`模板执行出错: ${error.message}`)
.catch(async (error: any) => {
await ConfirmDialogService.error({
title: '执行出错',
message: `模板执行出错: ${error.message}`,
confirmText: '确定'
})
})
}
</script>