Skip to content

Commit 1c46a34

Browse files
fix: virtualized tree
1 parent 2ddd3a9 commit 1c46a34

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

ui/src/components/folder-virtualized-tree/VirtualizedTree.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
:class="currentNodeKey === node.id ? 'is-current' : ''"
1818
>
1919
<el-icon
20+
@click.stop="stat.open = !stat.open"
2021
class="tree-arrow-icon"
2122
:class="stat.open ? 'rotate-90' : ''"
2223
:style="{ visibility: stat.children.length ? 'visible' : 'hidden' }"
@@ -59,7 +60,10 @@ const treeRef = ref<DraggableInstance | null>(null)
5960
const emit = defineEmits(['handleNodeClick', 'node-drop'])
6061
6162
const handleNodeClick = (node: any) => {
62-
node.open = !node.open
63+
if (node.data.id === props.currentNodeKey) {
64+
node.open = !node.open
65+
return
66+
}
6367
emit('handleNodeClick', node.data)
6468
}
6569
@@ -114,11 +118,24 @@ function onAfterDrop() {
114118
emit('node-drop', args[0], args[1], args[2])
115119
}
116120
}
121+
122+
const containsCurrentNodeKey = (node: any): boolean => {
123+
if (node.id === props.currentNodeKey) {
124+
return true
125+
}
126+
if (node.children && node.children.length) {
127+
return node.children.some((child: any) => containsCurrentNodeKey(child))
128+
}
129+
return false
130+
}
117131
const statHandler = (stat: any) => {
118132
stat.open = stat.level === 1
119133
if (filterText.value) {
120134
stat.open = true
121135
}
136+
if (containsCurrentNodeKey(stat.data)) {
137+
stat.open = true
138+
}
122139
return stat
123140
}
124141

ui/src/views/knowledge/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<template #left>
44
<h4 class="p-12-16 pb-0 mt-12">{{ $t('views.knowledge.title') }}</h4>
55

6-
<folder-tree
6+
<FolderVirtualizedTree
77
:source="SourceTypeEnum.KNOWLEDGE"
88
:data="folderList"
99
:currentNodeKey="folder.currentFolder?.id"

ui/src/views/tool/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<template #left>
44
<h4 class="p-12-16 pb-0 mt-12">{{ $t('views.tool.title') }}</h4>
55

6-
<folder-tree
6+
<FolderVirtualizedTree
77
:source="SourceTypeEnum.TOOL"
88
:data="folderList"
99
:currentNodeKey="folder.currentFolder?.id"
1010
@handleNodeClick="folderClickHandle"
11-
@refreshTree="refreshFolder"
1211
:shareTitle="$t('views.shared.shared_tool')"
1312
:showShared="permissionPrecise['is_share']()"
13+
@refreshTree="refreshFolder"
1414
:draggable="true"
1515
/>
1616
</template>

0 commit comments

Comments
 (0)