feat(react-web-next): 新增.editorconfig和.prettierrc配置文件,添加public/.gitkeep占位文件

This commit is contained in:
2025-09-23 10:32:35 +08:00
parent 10ddfd6f75
commit 408b500b6a
199 changed files with 16850 additions and 34874 deletions
+24
View File
@@ -0,0 +1,24 @@
export interface TreeNode<T=any> {
key: string | number;
title: string;
children?: TreeNode<T>[];
raw?: T;
}
export function buildTree<T extends { id: any; pId?: any; name?: string }>(list: T[]): TreeNode<T>[] {
const map = new Map<any, TreeNode<T>>();
const roots: TreeNode<T>[] = [];
list.forEach(item => {
map.set(item.id, { key: item.id, title: (item as any).title || item.name || String(item.id), raw: item, children: [] });
});
list.forEach(item => {
const node = map.get(item.id)!;
if (item.pId && map.has(item.pId)) {
map.get(item.pId)!.children!.push(node);
} else {
roots.push(node);
}
});
return roots;
}