feat: 添加控笔页

This commit is contained in:
R524809
2026-05-28 16:46:30 +08:00
parent 824e83c887
commit 2f0c4ab591
21 changed files with 1406 additions and 169 deletions
@@ -0,0 +1,69 @@
import type { DebugPublishMeta } from '../../utils/debugPublish';
import { inferGradeFromAge } from '../../utils/debugPublish';
import { PEN_CONTROL_MODE } from './generators/penControlGenerator';
interface PenControlWorksheetDefinition {
id: typeof PEN_CONTROL_MODE;
icon: string;
title: string;
subtitle: string;
ageMin: number;
ageMax: number;
difficulty: 1 | 2 | 3 | 4;
tags: string[];
sortOrder: number;
}
export const PEN_CONTROL_WORKSHEET_DEFINITIONS = [
{
id: PEN_CONTROL_MODE,
icon: 'edit',
title: '控笔组合练习',
subtitle: '3–6 种图形,每种占两行田字格',
ageMin: 3,
ageMax: 6,
difficulty: 1,
tags: ['控笔', '运笔', '田字格', '学前'],
sortOrder: 40,
},
] as const satisfies ReadonlyArray<PenControlWorksheetDefinition>;
type PenControlWorksheetRow = (typeof PEN_CONTROL_WORKSHEET_DEFINITIONS)[number];
const WORKSHEET_BY_ID = Object.fromEntries(
PEN_CONTROL_WORKSHEET_DEFINITIONS.map((m) => [m.id, m]),
) as Record<string, PenControlWorksheetRow>;
export const PEN_CONTROL_WORKSHEET_ID = PEN_CONTROL_WORKSHEET_DEFINITIONS[0].id;
export function getModeInfo(id: string) {
const m = WORKSHEET_BY_ID[id];
return m ? { title: m.title, desc: m.subtitle } : undefined;
}
export function isValidMode(id: string): boolean {
return id in WORKSHEET_BY_ID;
}
export function getPublishMetaByMode(id: string): DebugPublishMeta | null {
const m = WORKSHEET_BY_ID[id];
if (!m) return null;
return {
id: m.id,
title: m.title,
subtitle: m.subtitle,
category: 'chinese',
subcategory: 'pen-control',
path: `/chinesePages/penControlSheet/penControlSheet?id=${m.id}`,
ageMin: m.ageMin,
ageMax: m.ageMax,
grade: inferGradeFromAge(m.ageMin, m.ageMax),
difficulty: m.difficulty,
previewImg: '',
tags: [...m.tags],
isNew: true,
isHot: false,
sortOrder: m.sortOrder,
status: 'draft',
};
}