89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
import type { DebugPublishMeta } from '../../utils/debugPublish';
|
|
import { inferGradeFromAge } from '../../utils/debugPublish';
|
|
|
|
export type HandwritingSheetMode = 'hanzi-sheet' | 'hanzi-daily-checkin';
|
|
|
|
interface HandwritingSheetWorksheetDefinition {
|
|
id: HandwritingSheetMode;
|
|
icon: string;
|
|
title: string;
|
|
subtitle: string;
|
|
ageMin: number;
|
|
ageMax: number;
|
|
difficulty: 1 | 2 | 3 | 4;
|
|
tags: string[];
|
|
sortOrder: number;
|
|
}
|
|
|
|
export const HANDWRITING_SHEET_WORKSHEET_DEFINITIONS: HandwritingSheetWorksheetDefinition[] =
|
|
[
|
|
{
|
|
id: 'hanzi-sheet',
|
|
icon: 'draw-o',
|
|
title: '自定义练字帖',
|
|
subtitle: '自定义田字格练字帖',
|
|
ageMin: 4,
|
|
ageMax: 8,
|
|
difficulty: 2,
|
|
tags: ['练字', '字帖', '田字格', '汉字'],
|
|
sortOrder: 35,
|
|
},
|
|
{
|
|
id: 'hanzi-daily-checkin',
|
|
icon: 'task-o',
|
|
title: '汉字每日打卡',
|
|
subtitle: '每日 8 字带拼音笔顺打卡',
|
|
ageMin: 5,
|
|
ageMax: 8,
|
|
difficulty: 2,
|
|
tags: ['汉字', '每日练习', '每日打卡', '打卡', '拼音', '笔顺'],
|
|
sortOrder: 36,
|
|
},
|
|
];
|
|
|
|
type HandwritingSheetWorksheetRow =
|
|
(typeof HANDWRITING_SHEET_WORKSHEET_DEFINITIONS)[number];
|
|
|
|
const HANDWRITING_SHEET_WORKSHEET_BY_ID = Object.fromEntries(
|
|
HANDWRITING_SHEET_WORKSHEET_DEFINITIONS.map((item) => [item.id, item]),
|
|
) as Record<string, HandwritingSheetWorksheetRow>;
|
|
|
|
export const HANDWRITING_SHEET_MODE_OPTIONS =
|
|
HANDWRITING_SHEET_WORKSHEET_DEFINITIONS;
|
|
|
|
export const HANDWRITING_SHEET_WORKSHEET_ID =
|
|
HANDWRITING_SHEET_WORKSHEET_DEFINITIONS[0].id;
|
|
|
|
export function getModeInfo(id: string) {
|
|
const item = HANDWRITING_SHEET_WORKSHEET_BY_ID[id];
|
|
return item ? { title: item.title, desc: item.subtitle } : undefined;
|
|
}
|
|
|
|
export function isValidMode(id: string): boolean {
|
|
return id in HANDWRITING_SHEET_WORKSHEET_BY_ID;
|
|
}
|
|
|
|
export function getPublishMetaByMode(id: string): DebugPublishMeta | null {
|
|
const item = HANDWRITING_SHEET_WORKSHEET_BY_ID[id];
|
|
if (!item) return null;
|
|
|
|
return {
|
|
id: item.id,
|
|
title: item.title,
|
|
subtitle: item.subtitle,
|
|
category: 'chinese',
|
|
subcategory: 'hanzi-sheet',
|
|
path: `/chinesePages/handwritingSheet/handwritingSheet?id=${item.id}`,
|
|
ageMin: item.ageMin,
|
|
ageMax: item.ageMax,
|
|
grade: inferGradeFromAge(item.ageMin, item.ageMax),
|
|
difficulty: item.difficulty,
|
|
previewImg: '',
|
|
tags: [...item.tags],
|
|
isNew: false,
|
|
isHot: false,
|
|
sortOrder: item.sortOrder,
|
|
status: 'draft',
|
|
};
|
|
}
|