mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
修复脚本管理跳转逻辑
This commit is contained in:
parent
1961a6b913
commit
518436d5ca
|
@ -36,7 +36,7 @@ import EditScriptNameModal from './editNameModal';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import { history, useOutletContext, useLocation } from '@umijs/max';
|
import { history, useOutletContext, useLocation } from '@umijs/max';
|
||||||
import { parse } from 'query-string';
|
import { parse } from 'query-string';
|
||||||
import { depthFirstSearch } from '@/utils';
|
import { depthFirstSearch, findNode } from '@/utils';
|
||||||
import { SharedContext } from '@/layouts';
|
import { SharedContext } from '@/layouts';
|
||||||
import useFilterTreeData from '@/hooks/useFilterTreeData';
|
import useFilterTreeData from '@/hooks/useFilterTreeData';
|
||||||
import uniq from 'lodash/uniq';
|
import uniq from 'lodash/uniq';
|
||||||
|
@ -80,7 +80,7 @@ const Script = () => {
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
setData(data);
|
setData(data);
|
||||||
initState();
|
initState();
|
||||||
initGetScript();
|
initGetScript(data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => needLoading && setLoading(false));
|
.finally(() => needLoading && setLoading(false));
|
||||||
|
@ -100,7 +100,7 @@ const Script = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const initGetScript = () => {
|
const initGetScript = (_data: any) => {
|
||||||
const { p, s } = parse(history.location.search);
|
const { p, s } = parse(history.location.search);
|
||||||
if (s) {
|
if (s) {
|
||||||
const vkey = `${p}/${s}`;
|
const vkey = `${p}/${s}`;
|
||||||
|
@ -111,9 +111,12 @@ const Script = () => {
|
||||||
parent: p,
|
parent: p,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExpandedKeys([p]);
|
const item = findNode(_data, (c) => c.key === obj.node.key);
|
||||||
|
if (item) {
|
||||||
|
setExpandedKeys([p as string]);
|
||||||
onTreeSelect([vkey], obj);
|
onTreeSelect([vkey], obj);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSelect = (value: any, node: any) => {
|
const onSelect = (value: any, node: any) => {
|
||||||
|
|
|
@ -272,6 +272,29 @@ export function depthFirstSearch<
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findNode<T extends Record<string, any> & { children?: T[] }>(
|
||||||
|
children: T[],
|
||||||
|
condition: (column: T) => boolean,
|
||||||
|
) {
|
||||||
|
const c = [...children];
|
||||||
|
|
||||||
|
let item;
|
||||||
|
function find(cls: T[] | undefined): T | undefined {
|
||||||
|
if (!cls) return;
|
||||||
|
for (let i = 0; i < cls?.length; i++) {
|
||||||
|
if (condition(cls[i])) {
|
||||||
|
item = cls[i];
|
||||||
|
} else if (cls[i].children) {
|
||||||
|
find(cls[i].children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
find(c);
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
export function logEnded(log: string): boolean {
|
export function logEnded(log: string): boolean {
|
||||||
const endTips = [LOG_END_SYMBOL, '执行结束'];
|
const endTips = [LOG_END_SYMBOL, '执行结束'];
|
||||||
return endTips.some((x) => log.includes(x));
|
return endTips.some((x) => log.includes(x));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user