feat: 添加 @vueuse/core 依赖并重构模板树组件,优化创建模板界面
This commit is contained in:
1 parent
2f85832b89
commit
87ce5cb24f
5 files changed
+306
-156
No files matched your search
@@ -98,18 +98,14 @@
|
||||
<v-spacer />
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-treeview :items="templateTree" item-title="name" item-key="id" item-children="children" activatable
|
||||
open-all>
|
||||
<template v-slot:prepend="{ item }">
|
||||
<v-icon>
|
||||
{{
|
||||
item.type === 'directory'
|
||||
? 'mdi-folder'
|
||||
: 'mdi-file'
|
||||
}}
|
||||
</v-icon>
|
||||
</template>
|
||||
</v-treeview>
|
||||
<TemplateTree
|
||||
:items="templateTree"
|
||||
:height="400"
|
||||
:read-only="true"
|
||||
:empty-text="'模板结构为空'"
|
||||
:expanded="expandedTreeNodes"
|
||||
@update:expanded="expandedTreeNodes = $event"
|
||||
/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
@@ -144,6 +140,7 @@ import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useTemplateStore } from '@/renderer/store/template'
|
||||
import { Template } from '@/renderer/store/template'
|
||||
import TemplateTree from '@/renderer/components/TemplateTree.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const templateStore = useTemplateStore()
|
||||
@@ -160,6 +157,7 @@ const templates = computed(() => templateStore.templates)
|
||||
// Template detail view
|
||||
const showTemplateDetail = ref(false)
|
||||
const selectedTemplate = ref<Template | null>(null)
|
||||
const expandedTreeNodes = ref<string[]>([])
|
||||
|
||||
// Execute template
|
||||
const showExecuteDialog = ref(false)
|
||||
@@ -184,7 +182,7 @@ const templateTree = computed<TreeNode[]>(() => {
|
||||
selectedTemplate.value.directories.forEach((dir) => {
|
||||
items.push({
|
||||
id: `dir-${dir.path}`,
|
||||
name: dir.path,
|
||||
name: dir.path.split('/').pop() || dir.path, // Show just the directory name, not full path
|
||||
type: 'directory',
|
||||
children: []
|
||||
})
|
||||
@@ -194,11 +192,14 @@ const templateTree = computed<TreeNode[]>(() => {
|
||||
selectedTemplate.value.files.forEach((file) => {
|
||||
items.push({
|
||||
id: `file-${file.path}`,
|
||||
name: file.path,
|
||||
name: file.path.split('/').pop() || file.path, // Show just the file name, not full path
|
||||
type: 'file'
|
||||
})
|
||||
})
|
||||
|
||||
// Auto-expand all nodes when showing template details
|
||||
expandedTreeNodes.value = items.map(item => item.id)
|
||||
|
||||
return items
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user