memowake-front/components/utils/objectToCascader.ts
jinyaqiu 828e84710f
All checks were successful
Dev Deploy / Explore-Gitea-Actions (push) Successful in 24s
feat: 个人中心
2025-07-14 10:42:59 +08:00

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;
}