feat: 新增控笔练习,增加首页公告

This commit is contained in:
R524809
2026-05-29 10:21:39 +08:00
parent 2f0c4ab591
commit a6e8f4df02
28 changed files with 1045 additions and 672 deletions
@@ -1,78 +1,44 @@
import type { DebugPublishMeta } from '../../utils/debugPublish';
import { inferGradeFromAge } from '../../utils/debugPublish';
import type { TemplateType } from '../shared/draw/drawServiceFactory';
import type { TemplateType } from './draw/drawServiceFactory';
import { WORD_COLORING_WORKSHEET_DEFINITIONS } from '../../config/worksheets/wordColoring';
/** 本地 worksheet 元数据(与云库 `worksheets` 文档 `_id` 对齐) */
interface WordColoringWorksheetDefinition {
id: string;
templateType: TemplateType;
icon: string;
title: string;
subtitle: string;
ageMin: number;
ageMax: number;
difficulty: 1 | 2 | 3 | 4;
tags: string[];
sortOrder: number;
}
export const WORD_COLORING_WORKSHEET_DEFINITIONS = [
{
id: 'word-coloring-grid',
templateType: 'grid' as TemplateType,
icon: 'grid',
title: '网格涂色',
subtitle: '田字格涂色识字练习',
ageMin: 3,
ageMax: 6,
difficulty: 1,
tags: ['识字', '涂色', '田字格'],
sortOrder: 30,
},
{
id: 'word-coloring-find',
templateType: 'find' as TemplateType,
icon: 'search',
title: '找字涂色',
subtitle: '在字海中找到目标字并涂色',
ageMin: 3,
ageMax: 6,
difficulty: 1,
tags: ['识字', '涂色', '找字'],
sortOrder: 31,
},
] as const satisfies ReadonlyArray<WordColoringWorksheetDefinition>;
export { WORD_COLORING_WORKSHEET_DEFINITIONS };
type WordColoringWorksheetRow =
(typeof WORD_COLORING_WORKSHEET_DEFINITIONS)[number];
const WORD_COLORING_WORKSHEET_BY_ID = Object.fromEntries(
const WORKSHEET_BY_ID = Object.fromEntries(
WORD_COLORING_WORKSHEET_DEFINITIONS.map((m) => [m.id, m]),
) as Record<string, WordColoringWorksheetRow>;
/** 页面渲染用:模式选择器列表 */
export const WORD_COLORING_MODE_OPTIONS = WORD_COLORING_WORKSHEET_DEFINITIONS;
const WORD_COLORING_TEMPLATE_TYPES: Record<string, TemplateType> = {
'word-coloring-grid': 'grid',
'word-coloring-find': 'find',
};
/** 页面 pageInfoLookup 用 */
export function getModeInfo(id: string) {
const m = WORD_COLORING_WORKSHEET_BY_ID[id];
const m = WORKSHEET_BY_ID[id];
return m ? { title: m.title, desc: m.subtitle } : undefined;
}
/** 判断 id 是否有效 */
export function isValidMode(id: string): boolean {
return id in WORD_COLORING_WORKSHEET_BY_ID;
return id in WORKSHEET_BY_ID;
}
/** 根据 id 获取 templateType */
export function getTemplateType(id: string): TemplateType {
const m = WORD_COLORING_WORKSHEET_BY_ID[id];
return m?.templateType || 'grid';
return WORD_COLORING_TEMPLATE_TYPES[id] || 'grid';
}
/** 发布用:从当前 mode 生成 DebugPublishMeta */
export function getPublishMetaByMode(id: string): DebugPublishMeta | null {
const m = WORD_COLORING_WORKSHEET_BY_ID[id];
const m = WORKSHEET_BY_ID[id];
if (!m) return null;
return {
id: m.id,