feat: 优化模板树组件,默认展开所有节点,增强用户体验;在创建模板时添加新文件和目录后自动展开树节点
This commit is contained in:
1 parent
157bc47f3c
commit
f8890ff1e9
3 files changed
+38
-11
No files matched your search
@@ -5,7 +5,7 @@
|
||||
:height="height"
|
||||
>
|
||||
<v-treeview
|
||||
v-model:expanded="localExpanded"
|
||||
open-all
|
||||
:items="items"
|
||||
item-title="name"
|
||||
item-key="id"
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -531,7 +531,9 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
// Expand all nodes by default
|
||||
nextTick(() => {
|
||||
expandAll()
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in new issue
Block a user