116 lines
3.6 KiB
TypeScript
116 lines
3.6 KiB
TypeScript
import { CATEGORY_LIST_WITH_ALL } from '../../core/data/categories';
|
|
import { AGE_BANDS } from '../../core/data/difficulty';
|
|
import { CategoryId } from '../../core/models/category';
|
|
|
|
export type HomeDisplayItem = {
|
|
id: string;
|
|
title: string;
|
|
subtitle: string;
|
|
description?: string;
|
|
category: CategoryId;
|
|
ageBand: string;
|
|
difficulty: '入门' | '基础' | '进阶' | '挑战';
|
|
icon: string;
|
|
/** 横向滑动卡片顶部图,有则优先展示,可与 icon 二选一 */
|
|
previewImg?: string;
|
|
badge?: string;
|
|
path: string;
|
|
available: boolean;
|
|
source?: string;
|
|
};
|
|
|
|
export type HomeDisplaySection = {
|
|
id: string;
|
|
title: string;
|
|
subtitle: string;
|
|
morePath?: string;
|
|
items: HomeDisplayItem[];
|
|
};
|
|
|
|
export type HomeDisplayDataset = {
|
|
searchPlaceholder: string;
|
|
categoryTabs: Array<{
|
|
id: string;
|
|
name: string;
|
|
path?: string;
|
|
}>;
|
|
ageBands: Array<{
|
|
key: string;
|
|
label: string;
|
|
desc: string;
|
|
path: string;
|
|
}>;
|
|
featured: HomeDisplayItem[];
|
|
hot: HomeDisplayItem[];
|
|
sections: HomeDisplaySection[];
|
|
};
|
|
|
|
const HOME_CATEGORY_TABS: HomeDisplayDataset['categoryTabs'] =
|
|
CATEGORY_LIST_WITH_ALL.map(({ id, name }) => ({ id, name }));
|
|
|
|
const HOME_AGE_BANDS: HomeDisplayDataset['ageBands'] = AGE_BANDS.map(
|
|
(item, index) => ({
|
|
key: item.key,
|
|
label: item.label,
|
|
desc: ['启蒙认知', '基础练习', '能力提升', '幼小衔接', '知识拓展'][
|
|
index
|
|
],
|
|
path: '/pages/age/age',
|
|
}),
|
|
);
|
|
|
|
/** 首页固定:每日打卡练习(不随云端配置变化) */
|
|
export const HOME_DAILY_CHECKIN_ITEMS: HomeDisplayItem[] = [
|
|
{
|
|
id: 'hanzi-daily-checkin',
|
|
title: '汉字每日打卡',
|
|
subtitle: '每日 8 字带拼音笔顺打卡',
|
|
category: 'chinese',
|
|
ageBand: '5-8岁',
|
|
difficulty: '基础',
|
|
icon: '📝',
|
|
previewImg:
|
|
'cloud://cloud1-9gifs7a2756e2c87.636c-cloud1-9gifs7a2756e2c87-1351593184/assets/previews/chinese/hanzi-daily-checkin.jpg',
|
|
path: '/chinesePages/handwritingSheet/handwritingSheet?id=hanzi-daily-checkin',
|
|
available: true,
|
|
},
|
|
{
|
|
id: 'pinyin-daily',
|
|
title: '拼音每日打卡',
|
|
subtitle: '四宫格每日打卡练习',
|
|
category: 'pinyin',
|
|
ageBand: '6-8岁',
|
|
difficulty: '基础',
|
|
icon: '🔤',
|
|
previewImg:
|
|
'cloud://cloud1-9gifs7a2756e2c87.636c-cloud1-9gifs7a2756e2c87-1351593184/assets/previews/pinyin/pinyin-daily.jpg',
|
|
path: '/pinyinPages/pinyinDictation/pinyinDictation?id=pinyin-daily',
|
|
available: true,
|
|
},
|
|
{
|
|
id: 'letter-tracing-daily-checkin',
|
|
title: '字母每日打卡',
|
|
subtitle: '四宫格每日字母打卡练习',
|
|
category: 'english',
|
|
ageBand: '6-8岁',
|
|
difficulty: '基础',
|
|
icon: '🔠',
|
|
previewImg:
|
|
'cloud://cloud1-9gifs7a2756e2c87.636c-cloud1-9gifs7a2756e2c87-1351593184/assets/previews/english/letter-tracing-daily-checkin.jpg',
|
|
path: '/englishPages/letterTracing/letterTracing?id=letter-tracing-daily-checkin',
|
|
available: true,
|
|
},
|
|
];
|
|
|
|
/** 云端配置不可用时的空首页结构(仅保留 Tab / 分龄导航骨架) */
|
|
export function createEmptyHomeDataset(): HomeDisplayDataset {
|
|
return {
|
|
searchPlaceholder: '搜索你喜欢的练习册...',
|
|
categoryTabs: [...HOME_CATEGORY_TABS],
|
|
ageBands: [...HOME_AGE_BANDS],
|
|
featured: [],
|
|
hot: [],
|
|
sections: [],
|
|
};
|
|
}
|