style: utils code style

This commit is contained in:
xingyu4j
2025-04-23 14:37:35 +08:00
parent 455d396f96
commit 5988b85507
5 changed files with 134 additions and 132 deletions

View File

@@ -16,7 +16,7 @@ export const handleTree = (
data: TreeNode[],
id: string = 'id',
parentId: string = 'parentId',
children: string = 'children'
children: string = 'children',
): TreeNode[] => {
if (!Array.isArray(data)) {
console.warn('data must be an array');
@@ -25,10 +25,10 @@ export const handleTree = (
const config = {
id,
parentId,
childrenList: children
childrenList: children,
};
const childrenListMap: Record<string | number, TreeNode[]> = {};
const nodeIds: Record<string | number, TreeNode> = {};
const childrenListMap: Record<number | string, TreeNode[]> = {};
const nodeIds: Record<number | string, TreeNode> = {};
const tree: TreeNode[] = [];
// 1. 数据预处理
@@ -67,4 +67,4 @@ export const handleTree = (
}
return tree;
}
};