mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
修复查看脚本页搜索
This commit is contained in:
parent
164126ddc7
commit
325b423c4d
|
@ -7,32 +7,16 @@ import { request } from '@/utils/http';
|
||||||
import styles from './index.module.less';
|
import styles from './index.module.less';
|
||||||
|
|
||||||
function getFilterData(keyword: string, data: any) {
|
function getFilterData(keyword: string, data: any) {
|
||||||
const expandedKeys: string[] = [];
|
|
||||||
if (keyword) {
|
if (keyword) {
|
||||||
const tree: any = [];
|
const tree: any = [];
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
if (item.title.toLocaleLowerCase().includes(keyword)) {
|
if (item.title.toLocaleLowerCase().includes(keyword)) {
|
||||||
tree.push(item);
|
tree.push(item);
|
||||||
expandedKeys.push(...item.children.map((x: any) => x.key));
|
|
||||||
} else {
|
|
||||||
const children: any[] = [];
|
|
||||||
(item.children || []).forEach((subItem: any) => {
|
|
||||||
if (subItem.title.toLocaleLowerCase().includes(keyword)) {
|
|
||||||
children.push(subItem);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (children.length > 0) {
|
|
||||||
tree.push({
|
|
||||||
...item,
|
|
||||||
children,
|
|
||||||
});
|
|
||||||
expandedKeys.push(...children.map((x) => x.key));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return { tree, expandedKeys };
|
return { tree };
|
||||||
}
|
}
|
||||||
return { tree: data, expandedKeys };
|
return { tree: data };
|
||||||
}
|
}
|
||||||
|
|
||||||
const Script = () => {
|
const Script = () => {
|
||||||
|
@ -65,8 +49,6 @@ const Script = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSelect = (value: any, node: any) => {
|
const onSelect = (value: any, node: any) => {
|
||||||
console.log(value);
|
|
||||||
console.log(node);
|
|
||||||
setSelect(value);
|
setSelect(value);
|
||||||
setTitle(node.parent || node.value);
|
setTitle(node.parent || node.value);
|
||||||
getDetail(node);
|
getDetail(node);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user