feat: 添加全局确认对话框管理器,重构对话框服务,优化用户交互体验
This commit is contained in:
1 parent
4367fd6ed1
commit
562e4f5b9e
9 files changed
+543
-11
No files matched your search
@@ -358,6 +358,7 @@ import { useRoute, 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 route = useRoute()
|
||||
@@ -810,9 +811,17 @@ const selectAndAddFile = async () => {
|
||||
currentEditingItem.value = null
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
const goBack = async () => {
|
||||
if (hasChanges.value) {
|
||||
if (confirm('您有未保存的更改,确定要离开吗?')) {
|
||||
const confirmed = await ConfirmDialogService.confirm({
|
||||
title: '确认离开',
|
||||
message: '您有未保存的更改,确定要离开吗?',
|
||||
confirmText: '离开',
|
||||
cancelText: '取消',
|
||||
confirmColor: 'warning'
|
||||
})
|
||||
|
||||
if (confirmed) {
|
||||
router.push('/templates')
|
||||
}
|
||||
} else {
|
||||
@@ -904,8 +913,16 @@ const showEditFileDialog = (file: { path: string; content?: string; sourceFilePa
|
||||
// Variable to track the current item being edited
|
||||
const currentEditingItem = ref<{ path: string; type: 'directory' | 'file'; content?: string; sourceFilePath?: string } | null>(null)
|
||||
|
||||
const deleteItem = (item: TreeItem) => {
|
||||
if (!confirm('确定要删除此项吗?')) return
|
||||
const deleteItem = async (item: TreeItem) => {
|
||||
const confirmed = await ConfirmDialogService.confirm({
|
||||
title: '删除确认',
|
||||
message: '确定要删除此项吗?',
|
||||
confirmText: '删除',
|
||||
cancelText: '取消',
|
||||
confirmColor: 'error'
|
||||
})
|
||||
|
||||
if (!confirmed) return
|
||||
|
||||
if (item.type === 'directory') {
|
||||
// Find all directories that start with the item name (including the exact match)
|
||||
|
||||
Reference in new issue
Block a user