Files
doodle-mini/miniprogram/pages/home/home.data.ts
T
2026-07-29 17:15:25 +08:00

138 lines
4.2 KiB
TypeScript

import { CATEGORY_LIST_WITH_ALL } from '../../core/data/categories';
import { AGE_BANDS } from '../../core/data/difficulty';
import { CategoryId } from '../../core/models/category';
import { APP_VERSION } from '../../config/config';
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 type HomeNotice = {
id: string;
text: string;
/** 可选跳转路径,为空则点击不跳转 */
path?: string;
};
export const HOME_NOTICES: HomeNotice[] = [
{
id: 'welcome',
text: '欢迎来到 涂鸦丫,趣味练习纸任你选',
path: '/mathPages/clockReading/clockReading?id=clock-connect',
},
{
id: `update-${APP_VERSION}`,
text: `${APP_VERSION} 上线:新增幼儿认识时钟,连线练习题`,
path: '/mathPages/clockReading/clockReading?id=clock-connect',
},
];
/** 首页固定:每日打卡练习(不随云端配置变化) */
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: [],
};
}