20260507213409

This commit is contained in:
oneao committed 2026-05-07 21:34:09 +08:00
1 parent 3070eac71b
commit 4c7f516a03
204 files changed
+3623

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
import { IconAppFinance, IconAppClothes } from "@/components/iconfont";
export interface SubAppItem {
id: string;
title: string;
icon: any;
group: string;
description?: string;
}
type HeaderItem = {
type: "header";
title: string;
};
type GroupItem = {
type: "group";
title: string;
data: SubAppItem[];
};
export type AppListItem = HeaderItem | GroupItem;
export const SUB_APPS: SubAppItem[] = [
{
id: "/finance/home",
title: "记账",
icon: IconAppFinance,
group: "J",
description: "记录日常收支,管理你的每一笔钱",
},
{
id: "/clothes/home",
title: "衣服搭配",
icon: IconAppClothes,
group: "Y",
description: "帮你整理每日穿搭灵感",
},
];
export function getGroupedApps(keyword?: string): AppListItem[] {
let list = SUB_APPS;
if (keyword && keyword.trim()) {
const lower = keyword.toLowerCase();
list = SUB_APPS.filter((item) => item.title.toLowerCase().includes(lower));
}
const map: Record<string, SubAppItem[]> = {};
list.forEach((item) => {
if (!map[item.group]) map[item.group] = [];
map[item.group].push(item);
});
const sortedKeys = Object.keys(map).sort((a, b) => {
if (a === "#") return 1;
if (b === "#") return -1;
return a.localeCompare(b);
});
const data: AppListItem[] = [];
sortedKeys.forEach((key) => {
data.push({ type: "header", title: key });
data.push({ type: "group", title: key, data: map[key] });
});
return data;
}