Files
doodle-mini/miniprogram/englishPages/letterTracing/letterTracing.config.ts
T
2026-05-06 17:28:51 +08:00

141 lines
4.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { LetterTracingMode } from './generators/letter-tracing-generator';
import type { DebugPublishMeta } from '../../utils/debugPublish';
import { inferGradeFromAge } from '../../utils/debugPublish';
/** 本地 worksheet 元数据(与云库 `worksheets` 文档 `_id` 对齐) */
interface LetterTracingWorksheetDefinition {
id: LetterTracingMode;
icon: string;
title: string;
subtitle: string;
ageMin: number;
ageMax: number;
difficulty: 1 | 2 | 3 | 4;
tags: string[];
sortOrder: number;
}
export const LETTER_TRACING_WORKSHEET_DEFINITIONS = [
{
id: 'letter-tracing-single',
icon: 'start-a',
title: '默认字帖',
subtitle: '配图、例句与描红',
ageMin: 4,
ageMax: 7,
difficulty: 1,
tags: ['字母', '描红', '看图描红'],
sortOrder: 42,
},
{
id: 'letter-tracing-upper-lower',
icon: 'draw-o',
title: '基础描红',
subtitle: 'Uppercase / Lowercase 总览',
ageMin: 5,
ageMax: 7,
difficulty: 1,
tags: ['字母', '描红', '字母总览'],
sortOrder: 44,
},
{
id: 'letter-tracing-case-pairing',
icon: 'font-size',
title: '大小写对照',
subtitle: '半组字母左大写右小写',
ageMin: 5,
ageMax: 7,
difficulty: 1,
tags: ['字母', '描红', '大小写练习'],
sortOrder: 45,
},
{
id: 'letter-tracing-two-column',
icon: 'two-columns',
title: '两列描红',
subtitle: '左 AM、右 NZ 配对描红',
ageMin: 5,
ageMax: 7,
difficulty: 1,
tags: ['字母', '描红', '两列练习'],
sortOrder: 43,
},
{
id: 'letter-tracing-half',
icon: 'square-half',
title: '13字母半表',
subtitle: '每行一个字母,13 字母半表',
ageMin: 5,
ageMax: 8,
difficulty: 2,
tags: ['字母', '描红', '半表练习'],
sortOrder: 47,
},
{
id: 'letter-tracing-three',
icon: 'ABC-list',
title: '三字母精练',
subtitle: '每页聚焦 3 个字母深度书写',
ageMin: 5,
ageMax: 7,
difficulty: 2,
tags: ['字母', '描红', '三字母精练'],
sortOrder: 46,
},
{
id: 'letter-tracing-daily-checkin',
icon: 'task-o',
title: '每日打卡',
subtitle: '四宫格每日字母打卡练习',
ageMin: 6,
ageMax: 8,
difficulty: 2,
tags: ['字母', '描红', '每日打卡'],
sortOrder: 48,
},
] as const satisfies ReadonlyArray<LetterTracingWorksheetDefinition>;
type LetterTracingWorksheetRow = (typeof LETTER_TRACING_WORKSHEET_DEFINITIONS)[number];
const LETTER_TRACING_WORKSHEET_BY_ID = Object.fromEntries(
LETTER_TRACING_WORKSHEET_DEFINITIONS.map((m) => [m.id, m]),
) as Record<string, LetterTracingWorksheetRow>;
/** 页面渲染用:模式选择器列表(与 `LETTER_TRACING_WORKSHEET_DEFINITIONS` 同义) */
export const LETTER_TRACING_MODE_OPTIONS = LETTER_TRACING_WORKSHEET_DEFINITIONS;
/** 页面 pageInfoLookup 用 */
export function getModeInfo(id: string) {
const m = LETTER_TRACING_WORKSHEET_BY_ID[id];
return m ? { title: m.title, desc: m.subtitle } : undefined;
}
/** 判断 id 是否有效 */
export function isValidMode(id: string): boolean {
return id in LETTER_TRACING_WORKSHEET_BY_ID;
}
/** 发布用:从当前 mode 生成 DebugPublishMeta */
export function getPublishMetaByMode(id: string): DebugPublishMeta | null {
const m = LETTER_TRACING_WORKSHEET_BY_ID[id];
if (!m) return null;
return {
id: m.id,
title: m.title,
subtitle: m.subtitle,
category: 'english',
subcategory: 'letter-tracing',
path: `/englishPages/letterTracing/letterTracing?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',
};
}