mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 09:34:31 +08:00
升级umi4.0,修复新建脚本
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { extend } from 'umi-request';
|
||||
import { message } from 'antd';
|
||||
import config from './config';
|
||||
import { history } from 'umi';
|
||||
import { history } from '@umijs/max';
|
||||
|
||||
message.config({
|
||||
duration: 1.5,
|
||||
|
||||
@@ -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