feat: 优化模板树组件,默认展开所有节点,增强用户体验;在创建模板时添加新文件和目录后自动展开树节点
This commit is contained in:
1 parent
157bc47f3c
commit
f8890ff1e9
3 files changed
+39
-12
No files matched your search
@@ -5,7 +5,7 @@
|
|||||||
:height="height"
|
:height="height"
|
||||||
>
|
>
|
||||||
<v-treeview
|
<v-treeview
|
||||||
v-model:expanded="localExpanded"
|
open-all
|
||||||
:items="items"
|
:items="items"
|
||||||
item-title="name"
|
item-title="name"
|
||||||
item-key="id"
|
item-key="id"
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ export default createRouter({
|
|||||||
titleKey: 'title.create-template'
|
titleKey: 'title.create-template'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/create-template/:id',
|
||||||
|
component: () => import('@/renderer/screens/CreateTemplateScreen.vue'),
|
||||||
|
meta: {
|
||||||
|
titleKey: 'title.edit-template'
|
||||||
|
},
|
||||||
|
props: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/second',
|
path: '/second',
|
||||||
component: () => import('@/renderer/screens/SecondScreen.vue'),
|
component: () => import('@/renderer/screens/SecondScreen.vue'),
|
||||||
|
|||||||
@@ -531,7 +531,9 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expand all nodes by default
|
// Expand all nodes by default
|
||||||
expandAll()
|
nextTick(() => {
|
||||||
|
expandAll()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
@@ -625,16 +627,15 @@ const confirmAddDirectory = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showDirectoryDialog.value = false
|
showDirectoryDialog.value = false
|
||||||
newDirectoryPath.value = ''
|
|
||||||
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
||||||
currentEditingItem.value = null
|
currentEditingItem.value = null
|
||||||
|
|
||||||
// If we added to a parent directory, make sure it's expanded
|
// After adding a new directory, expand all nodes to show the new structure
|
||||||
if (parentDirectoryForNewItems.value) {
|
nextTick(() => {
|
||||||
if (!expandedNodes.value.includes(`dir-${parentDirectoryForNewItems.value}`)) {
|
expandAll()
|
||||||
expandedNodes.value.push(`dir-${parentDirectoryForNewItems.value}`)
|
})
|
||||||
}
|
|
||||||
}
|
newDirectoryPath.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to update paths when a directory is renamed
|
// Helper function to update paths when a directory is renamed
|
||||||
@@ -737,9 +738,15 @@ const selectAndAddFile = async () => {
|
|||||||
isAutoFindMode.value = false
|
isAutoFindMode.value = false
|
||||||
|
|
||||||
showFileDialog.value = false
|
showFileDialog.value = false
|
||||||
newFilePath.value = ''
|
|
||||||
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
||||||
currentEditingItem.value = null
|
currentEditingItem.value = null
|
||||||
|
|
||||||
|
// After adding new files, expand all nodes to show the new structure
|
||||||
|
nextTick(() => {
|
||||||
|
expandAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
newFilePath.value = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,9 +764,15 @@ const selectAndAddFile = async () => {
|
|||||||
isAutoFindMode.value = false
|
isAutoFindMode.value = false
|
||||||
|
|
||||||
showFileDialog.value = false
|
showFileDialog.value = false
|
||||||
newFilePath.value = ''
|
|
||||||
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
parentDirectoryForNewItems.value = null // Clear parent context after creation
|
||||||
currentEditingItem.value = null
|
currentEditingItem.value = null
|
||||||
|
|
||||||
|
// After adding a new file, expand all nodes to show the new structure
|
||||||
|
nextTick(() => {
|
||||||
|
expandAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
newFilePath.value = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,9 +786,15 @@ const selectAndAddFile = async () => {
|
|||||||
isAutoFindMode.value = false
|
isAutoFindMode.value = false
|
||||||
|
|
||||||
showFileDialog.value = false
|
showFileDialog.value = false
|
||||||
newFilePath.value = ''
|
|
||||||
parentDirectoryForNewItems.value = null
|
parentDirectoryForNewItems.value = null
|
||||||
currentEditingItem.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 () => {
|
const goBack = async () => {
|
||||||
|
|||||||
Reference in new issue
Block a user