All checks were successful
Dev Deploy / Explore-Gitea-Actions (push) Successful in 24s
22 lines
508 B
TypeScript
22 lines
508 B
TypeScript
import { GroupedData, TargetItem } from "@/types/user";
|
|
|
|
export function transformData(data: GroupedData): TargetItem[] {
|
|
const result: TargetItem[] = [];
|
|
|
|
for (const category in data) {
|
|
const items = data[category];
|
|
|
|
// 构建该类别的 children
|
|
const children = items.map(item => ({
|
|
name: item.display_name,
|
|
value: item.id
|
|
}));
|
|
|
|
result.push({
|
|
name: category,
|
|
children,
|
|
});
|
|
}
|
|
|
|
return result;
|
|
} |