u
This commit is contained in:
1 parent
230f3bdf5c
commit
6300778150
36 files changed
+867
-322
No files matched your search
@@ -1,50 +1,70 @@
|
||||
import { LucideIcon } from "lucide-react-native";
|
||||
import { IconAppFinance, IconAppClothes } from "@/components/iconfont";
|
||||
|
||||
import {
|
||||
StarIcon,
|
||||
HouseIcon,
|
||||
LayoutGridIcon,
|
||||
UserRoundIcon,
|
||||
MessageCircleIcon,
|
||||
} from "lucide-react-native";
|
||||
|
||||
export interface NavItem {
|
||||
export interface SubAppItem {
|
||||
id: string;
|
||||
title: string;
|
||||
icon?: LucideIcon;
|
||||
isCenter?: boolean;
|
||||
|
||||
children?: NavItem[];
|
||||
icon: any;
|
||||
group: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
// 主
|
||||
export const MainRoutes: NavItem[] = [
|
||||
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: "/",
|
||||
title: "首页",
|
||||
icon: HouseIcon,
|
||||
id: "/money/home",
|
||||
title: "记账",
|
||||
icon: IconAppFinance,
|
||||
group: "J",
|
||||
description: "记录日常收支,管理你的每一笔钱",
|
||||
},
|
||||
{
|
||||
id: "/star",
|
||||
title: "关注",
|
||||
icon: StarIcon,
|
||||
},
|
||||
{
|
||||
id: "/app",
|
||||
title: "",
|
||||
icon: LayoutGridIcon,
|
||||
isCenter: true,
|
||||
},
|
||||
{
|
||||
id: "/chat",
|
||||
title: "聊天",
|
||||
icon: MessageCircleIcon,
|
||||
},
|
||||
{
|
||||
id: "/my",
|
||||
title: "我的",
|
||||
icon: UserRoundIcon,
|
||||
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;
|
||||
}
|
||||
Reference in new issue
Block a user