Files
doodle-mini/miniprogram/pinyinPages/pinyinDictation/pinyinDictation.config.ts
T
2026-05-22 11:29:08 +08:00

123 lines
3.6 KiB
TypeScript

import type { DebugPublishMeta } from '../../utils/debugPublish';
import { inferGradeFromAge } from '../../utils/debugPublish';
export type PinyinDictationMode =
| 'pinyin-tracing'
| 'pinyin-dictation'
| 'pinyin-tracing-v2'
| 'pinyin-dictation-v2'
| 'pinyin-daily';
interface PinyinDictationWorksheetDefinition {
id: string; // 使用 string 以兼容动态生成的 ID
icon: string;
title: string;
subtitle: string;
ageMin: number;
ageMax: number;
difficulty: 1 | 2 | 3 | 4;
tags: string[];
sortOrder: number;
}
export const PINYIN_DICTATION_WORKSHEET_DEFINITIONS: PinyinDictationWorksheetDefinition[] =
[
{
id: 'pinyin-tracing',
icon: 'draw-o',
title: '拼音描红练习',
subtitle: '跟着描红学拼音字母',
ageMin: 5,
ageMax: 7,
difficulty: 1,
tags: ['拼音', '描红', '声母', '韵母'],
sortOrder: 50,
},
{
id: 'pinyin-dictation',
icon: 'start-a',
title: '拼音默写练习',
subtitle: '空白格子默写拼音字母',
ageMin: 6,
ageMax: 8,
difficulty: 2,
tags: ['拼音', '默写', '声母', '韵母'],
sortOrder: 51,
},
{
id: 'pinyin-tracing-v2',
icon: 'pen-draw',
title: '拼音描红 8 列',
subtitle: '跟写描红,声韵分块',
ageMin: 5,
ageMax: 7,
difficulty: 1,
tags: ['拼音', '描红', '声母', '韵母'],
sortOrder: 52,
},
{
id: 'pinyin-dictation-v2',
icon: 'ABC-underline',
title: '拼音默写 8 列',
subtitle: '空白默写,声韵分块',
ageMin: 6,
ageMax: 8,
difficulty: 2,
tags: ['拼音', '默写', '声母', '韵母'],
sortOrder: 53,
},
{
id: 'pinyin-daily',
icon: 'task-o',
title: '拼音每日打卡',
subtitle: '四宫格每日打卡练习',
ageMin: 5,
ageMax: 7,
difficulty: 2,
tags: ['拼音', '每日练习', '打卡'],
sortOrder: 54,
},
];
type PinyinDictationWorksheetRow =
(typeof PINYIN_DICTATION_WORKSHEET_DEFINITIONS)[number];
const PINYIN_DICTATION_WORKSHEET_BY_ID = Object.fromEntries(
PINYIN_DICTATION_WORKSHEET_DEFINITIONS.map((m) => [m.id, m]),
) as Record<string, PinyinDictationWorksheetRow>;
export const PINYIN_DICTATION_MODE_OPTIONS =
PINYIN_DICTATION_WORKSHEET_DEFINITIONS;
export function getModeInfo(id: string) {
const m = PINYIN_DICTATION_WORKSHEET_BY_ID[id];
return m ? { title: m.title, desc: m.subtitle } : undefined;
}
export function isValidMode(id: string): boolean {
return id in PINYIN_DICTATION_WORKSHEET_BY_ID;
}
export function getPublishMetaByMode(id: string): DebugPublishMeta | null {
const m = PINYIN_DICTATION_WORKSHEET_BY_ID[id];
if (!m) return null;
return {
id: m.id,
title: m.title,
subtitle: m.subtitle,
category: 'pinyin',
subcategory: 'pinyin-dictation',
path: `/pinyinPages/pinyinDictation/pinyinDictation?id=${m.id}`,
ageMin: m.ageMin,
ageMax: m.ageMax,
grade: inferGradeFromAge(m.ageMin, m.ageMax),
difficulty: m.difficulty,
previewImg: '',
tags: [...m.tags],
isNew: false,
isHot: false,
sortOrder: m.sortOrder,
status: 'draft',
};
}