feat: 优化模板树组件,默认展开所有节点,增强用户体验;在创建模板时添加新文件和目录后自动展开树节点

This commit is contained in:
zhanggy committed 2025-10-28 17:48:41 +08:00
1 parent 157bc47f3c
commit f8890ff1e9
3 files changed
+38 -11

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@
:height="height"
>
<v-treeview
v-model:expanded="localExpanded"
open-all
:items="items"
item-title="name"
item-key="id"
+8
View File
@@ -22,6 +22,14 @@ export default createRouter({
titleKey: 'title.create-template'
}
},
{
path: '/create-template/:id',
component: () => import('@/renderer/screens/CreateTemplateScreen.vue'),
meta: {
titleKey: 'title.edit-template'
},
props: true
},
{
path: '/second',
component: () => import('@/renderer/screens/SecondScreen.vue'),
+29 -10
View File
@@ -531,8 +531,10 @@ onMounted(async () => {
}
// Expand all nodes by default
nextTick(() => {
expandAll()
})
})
onUnmounted(() => {
window.removeEventListener('resize', updateTreeHeight)
@@ -625,16 +627,15 @@ const confirmAddDirectory = () => {
}
showDirectoryDialog.value = false
newDirectoryPath.value = ''
parentDirectoryForNewItems.value = null // Clear parent context after creation
currentEditingItem.value = null
// If we added to a parent directory, make sure it's expanded
if (parentDirectoryForNewItems.value) {
if (!expandedNodes.value.includes(`dir-${parentDirectoryForNewItems.value}`)) {
expandedNodes.value.push(`dir-${parentDirectoryForNewItems.value}`)
}
}
// After adding a new directory, expand all nodes to show the new structure
nextTick(() => {
expandAll()
})
newDirectoryPath.value = ''
}
// Helper function to update paths when a directory is renamed
@@ -737,9 +738,15 @@ const selectAndAddFile = async () => {
isAutoFindMode.value = false
showFileDialog.value = false
newFilePath.value = ''
parentDirectoryForNewItems.value = null // Clear parent context after creation
currentEditingItem.value = null
// After adding new files, expand all nodes to show the new structure
nextTick(() => {
expandAll()
})
newFilePath.value = ''
return
}
@@ -757,9 +764,15 @@ const selectAndAddFile = async () => {
isAutoFindMode.value = false
showFileDialog.value = false
newFilePath.value = ''
parentDirectoryForNewItems.value = null // Clear parent context after creation
currentEditingItem.value = null
// After adding a new file, expand all nodes to show the new structure
nextTick(() => {
expandAll()
})
newFilePath.value = ''
return
}
@@ -773,9 +786,15 @@ const selectAndAddFile = async () => {
isAutoFindMode.value = false
showFileDialog.value = false
newFilePath.value = ''
parentDirectoryForNewItems.value = null
currentEditingItem.value = null
// After adding a new file, expand all nodes to show the new structure
nextTick(() => {
expandAll()
})
newFilePath.value = ''
}
const goBack = async () => {