fix: expand path directories on row click

This commit is contained in:
jxxghp
2026-04-10 15:44:13 +08:00
parent ba7d4cd392
commit 59c73facfe
+15
View File
@@ -103,8 +103,21 @@ const selectedPath = computed(() => {
return '' return ''
}) })
function isFileItem(value: unknown): value is FileItem {
return typeof value === 'object' && value !== null && 'path' in value && 'type' in value
}
function activateDir({ id }: { id: unknown }) {
const item = isFileItem(id) ? id : typeof id === 'string' ? findPath(treeItems.value[0], id) : null
if (!item || item.type !== 'dir') return
activedDirs.value = [item]
}
watch(activedDirs, newVal => { watch(activedDirs, newVal => {
if (!newVal.length) return if (!newVal.length) return
emit('update:modelValue', selectedPath.value) emit('update:modelValue', selectedPath.value)
}) })
@@ -165,8 +178,10 @@ watch(
activatable activatable
return-object return-object
max-height="20rem" max-height="20rem"
open-on-click
expand-icon="mdi-folder" expand-icon="mdi-folder"
collapse-icon="mdi-folder-open" collapse-icon="mdi-folder-open"
@click:open="activateDir"
/> />
</VMenu> </VMenu>
</div> </div>