fix(sidebar): 修复侧边栏树状态显示

This commit is contained in:
t8y2 committed 2026-05-11 02:16:36 +08:00
1 parent 043bd5dd8d
commit 9355fa7e93
7 files changed
+180 -95

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import type { TreeNodeType } from "@/types/database";
const leafTypes: Set<TreeNodeType> = new Set([
"column",
"index",
"fkey",
"trigger",
"object-browser",
"redis-db",
"mongo-collection",
"saved-sql-file",
]);
export function treeItemPaddingLeft(depth: number): string {
return `${depth * 16 + 8}px`;
}
export function canTreeNodeExpand(type: TreeNodeType): boolean {
return !leafTypes.has(type);
}
export function canTreeNodeShowExpander({ type, childCount }: { type: TreeNodeType; childCount?: number }): boolean {
if (!canTreeNodeExpand(type)) return false;
if (type === "saved-sql-root" || type === "saved-sql-folder") {
return (childCount ?? 0) > 0;
}
return true;
}