Feat: Adapted for the upgraded knowledge graph of @antv/g6. (#14103)

### What problem does this PR solve?

Feat: Adapted for the upgraded knowledge graph of @antv/g6.

### Type of change

- [x] Refactoring
This commit is contained in:
balibabu
2026-04-14 16:33:52 +08:00
committed by GitHub
parent 1376c004a9
commit 27ebc64ec0
6 changed files with 179 additions and 539 deletions

View File

@@ -10,14 +10,16 @@ export function groupListByType<T extends Record<string, any>>(
labelField: string,
) {
const fileTypeList: FilterType[] = [];
list.forEach((x) => {
const item = fileTypeList.find((y) => y.id === x[idField]);
if (!item) {
fileTypeList.push({ id: x[idField], label: x[labelField], count: 1 });
} else {
item.count += 1;
}
});
if (Array.isArray(list)) {
list.forEach((x) => {
const item = fileTypeList.find((y) => y.id === x[idField]);
if (!item) {
fileTypeList.push({ id: x[idField], label: x[labelField], count: 1 });
} else {
item.count += 1;
}
});
}
return fileTypeList;
}