From ccb91731fc13822a5d52c7a63ff04bc83db76096 Mon Sep 17 00:00:00 2001 From: Jokul Date: Sat, 11 Jul 2026 15:35:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=91=E7=8A=B6=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=8E=8B=E7=BC=A9=20-=20=E5=8D=95=E5=AD=90?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=96=87=E4=BB=B6=E5=A4=B9=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文件夹只有 1 个子节点时合并名称, 避免不必要的层级展开: - a:b:c:d (单个 key) 直接显示为 a:b:c:d 而非 4 层嵌套 - a:b:c + a:b:d 仍展开为 a > b > {c, d} (b 有 2 个子节点) - a:b:c + a:d:e 显示为 a > {b:c, d:e} (b/d 各 1 子节点, 合并) --- src/renderer/src/components/KeyList.vue | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/KeyList.vue b/src/renderer/src/components/KeyList.vue index e134b53..8bdac27 100644 --- a/src/renderer/src/components/KeyList.vue +++ b/src/renderer/src/components/KeyList.vue @@ -452,7 +452,27 @@ const treeData = computed(() => { updateCounts(node) } - return root + // 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) }) function isFolderExpanded(path: string): boolean {