mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +08:00
升级umi4.0,修复新建脚本
This commit is contained in:
1 parent
518e8903a3
commit
1e55f4065d
28 files changed
+227
-126
No files matched your search
@@ -241,3 +241,31 @@ export function exportJson(name: string, data: string) {
|
||||
createA.download = name;
|
||||
automaticClick(createA);
|
||||
}
|
||||
|
||||
export function depthFirstSearch<
|
||||
T extends Record<string, any> & { children?: T[] },
|
||||
>(children: T[], condition: (column: T) => boolean, item: T) {
|
||||
const c = [...children];
|
||||
const keys = [];
|
||||
|
||||
(function find(cls: T[] | undefined) {
|
||||
if (!cls) return;
|
||||
for (let i = 0; i < cls?.length; i++) {
|
||||
if (condition(cls[i])) {
|
||||
if (cls[i].children) {
|
||||
cls[i].children!.unshift(item);
|
||||
} else {
|
||||
cls[i].children = [item];
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (cls[i].children) {
|
||||
keys.push(cls[i].key);
|
||||
find(cls[i].children);
|
||||
}
|
||||
}
|
||||
})(c);
|
||||
|
||||
console.log(keys);
|
||||
return c;
|
||||
}
|
||||
Reference in new issue
Block a user