feat: 分类数据统一

This commit is contained in:
R524809
2026-04-23 10:54:22 +08:00
parent 2a1dbad164
commit b2ab123b4f
15 changed files with 757 additions and 221 deletions
+19 -44
View File
@@ -1,52 +1,27 @@
import type { CategoryType } from '../models/category';
export const CATEGORIES: CategoryType[] = [
{
id: 'math',
name: '数感启蒙',
icon: '📐',
color: '#e3f2fd',
gradient: ['#fff9c4', '#fff176'],
},
{
id: 'chinese',
name: '趣味识字',
icon: '✏️',
color: '#e8f5e9',
gradient: ['#c8e6c9', '#a5d6a7'],
},
{
id: 'english',
name: '英语启蒙',
icon: '🔤',
color: '#e0f7fa',
gradient: ['#b2ebf2', '#80deea'],
},
// {
// id: 'focus',
// name: '专注力',
// icon: '🧩',
// color: '#f3e5f5',
// gradient: ['#e1bee7', '#ce93d8'],
// },
{
id: 'puzzle',
name: '益智游戏',
icon: '🧩',
color: '#fff3e0',
gradient: ['#ffe0b2', '#ffcc80'],
},
{
id: 'craft',
name: '创意手工',
icon: '🌈',
color: '#fce4ec',
gradient: ['#f8bbd0', '#f48fb1'],
},
export const ALL_CATEGORY: CategoryType = {
id: 'all',
name: '全部',
icon: '📋',
};
export const CATEGORY_LIST: CategoryType[] = [
{ id: 'math', name: '数感启蒙', icon: '📐' },
{ id: 'puzzle', name: '益智游戏', icon: '🧩' },
{ id: 'pinyin', name: '汉语拼音', icon: '🔤' },
{ id: 'chinese', name: '趣味识字', icon: '✏️' },
{ id: 'english', name: '英语启蒙', icon: '🔤' },
{ id: 'craft', name: '创意手工', icon: '🌈' },
];
export const CATEGORY_LIST_WITH_ALL: CategoryType[] = [
ALL_CATEGORY,
...CATEGORY_LIST,
];
export function getCategoryById(id: string): CategoryType | undefined {
return CATEGORIES.find((c) => c.id === id);
return CATEGORY_LIST_WITH_ALL.find((c) => c.id === id);
}
export function getCategoryName(id: string): string {
+4 -6
View File
@@ -1,13 +1,11 @@
import type { WorksheetCategory } from './worksheet';
/** Tab / 首页用的分类展示模型 */
export interface CategoryType {
id: WorksheetCategory;
id: string;
name: string;
icon: string;
color: string;
/** 分类用于背景或装饰的渐变色,数组中为渐变起止的两个颜色值 */
gradient: [string, string];
img?: string;
color?: string;
sortOrder?: number;
}
/** 云集合 `categories` 文档(与小程序云开发方案 §3.4 对齐) */