@@ -452,27 +452,7 @@ const treeData = computed<TreeNode[]>(() => {
|
||||
updateCounts(node)
|
||||
}
|
||||
|
||||
// Compress: merge folders that have exactly 1 child into a single node
|
||||
// e.g. a > b > c (single key "a:b:c") becomes one leaf "a:b:c"
|
||||
function compress(nodes: TreeNode[]): TreeNode[] {
|
||||
return nodes.map(node => {
|
||||
if (node.isLeaf) return node
|
||||
const children = compress(node.children)
|
||||
if (children.length === 1) {
|
||||
const child = children[0]
|
||||
return {
|
||||
name: node.name + separator + child.name,
|
||||
fullPath: child.fullPath,
|
||||
isLeaf: child.isLeaf,
|
||||
children: child.children,
|
||||
count: child.count,
|
||||
}
|
||||
}
|
||||
return { ...node, children }
|
||||
})
|
||||
}
|
||||
|
||||
return compress(root)
|
||||
return root
|
||||
})
|
||||
|
||||
function isFolderExpanded(path: string): boolean {
|
||||
|
||||
Reference in New Issue
Block a user