import type { DebugPublishMeta } from '../../utils/debugPublish'; import { inferGradeFromAge } from '../../utils/debugPublish'; interface FocusDrawDefinition { id: string; title: string; subtitle: string; ageMin: number; ageMax: number; difficulty: 1 | 2 | 3 | 4; tags: string[]; sortOrder: number; } const FOCUS_DRAW_DEFINITIONS = [ { id: 'color-shape-match', title: '根据颜色画图形', subtitle: '根据颜色画出对应图形', ageMin: 4, ageMax: 6, difficulty: 2, tags: ['专注力', '颜色', '图形'], sortOrder: 201, }, { id: 'shape-symbol', title: '图形符号配对', subtitle: '根据图形画对应符号', ageMin: 4, ageMax: 6, difficulty: 2, tags: ['专注力', '图形', '符号'], sortOrder: 202, }, { id: 'position-coloring', title: '方位涂涂乐', subtitle: '观察位置,在方格中涂色', ageMin: 4, ageMax: 6, difficulty: 2, tags: ['专注力', '方位', '涂色'], sortOrder: 203, }, { id: 'color-pattern', title: '颜色找规律', subtitle: '观察颜色规律,在空白图形中涂色', ageMin: 4, ageMax: 6, difficulty: 2, tags: ['专注力', '颜色', '规律'], sortOrder: 204, }, { id: 'match-connect', title: '连连看', subtitle: '根据物品连一连', ageMin: 3, ageMax: 6, difficulty: 1, tags: ['专注力', '连线', '匹配'], sortOrder: 205, }, { id: 'line-recognition', title: '线条识别', subtitle: '认识不同线条,画出颜色对应的线条', ageMin: 3, ageMax: 5, difficulty: 1, tags: ['专注力', '线条', '识别', '控笔'], sortOrder: 206, }, { id: 'grid-reasoning', title: '方格推理', subtitle: '推理出合并方格并连线', ageMin: 5, ageMax: 7, difficulty: 3, tags: ['专注力', '方格', '推理', '逻辑思维'], sortOrder: 207, }, { id: 'code-connect', title: '译码连线', subtitle: '按数字顺序将数字对应颜色连线', ageMin: 5, ageMax: 7, difficulty: 3, tags: ['专注力', '译码', '连线', '逻辑思维'], sortOrder: 208, }, { id: 'dot-connect', title: '数字点连线', subtitle: '按数字顺序连点成图', ageMin: 3, ageMax: 6, difficulty: 1, tags: ['专注力', '数字', '连线'], sortOrder: 209, }, { id: 'grid-drawing-3x3', title: '格子仿画 3×3', subtitle: '简单有趣,培养专注力', ageMin: 3, ageMax: 5, difficulty: 1, tags: ['专注力', '格子仿画', '观察'], sortOrder: 210, }, { id: 'grid-drawing-5x5', title: '格子仿画 5×5', subtitle: '创意挑战,提升观察力', ageMin: 4, ageMax: 6, difficulty: 2, tags: ['专注力', '格子仿画', '观察'], sortOrder: 211, }, { id: 'grid-drawing-7x7', title: '格子仿画 7×7', subtitle: '大师挑战,锻炼耐心', ageMin: 5, ageMax: 8, difficulty: 3, tags: ['专注力', '格子仿画', '耐心'], sortOrder: 212, }, ] as const satisfies ReadonlyArray; type FocusDrawDefinitionItem = (typeof FOCUS_DRAW_DEFINITIONS)[number]; const FOCUS_DRAW_BY_ID = Object.fromEntries( FOCUS_DRAW_DEFINITIONS.map((item) => [item.id, item]), ) as Record; function resolveFocusPublishId( routeId: string, selectedTypeId: string, mode?: string, ): string { if (selectedTypeId === 'grid-drawing') { return `grid-drawing-${mode || '3x3'}`; } if (routeId in FOCUS_DRAW_BY_ID) { return routeId; } return selectedTypeId; } export function getPublishMetaByFocusState( routeId: string, selectedTypeId: string, mode?: string, ): DebugPublishMeta | null { const id = resolveFocusPublishId(routeId, selectedTypeId, mode); const item = FOCUS_DRAW_BY_ID[id]; if (!item) return null; return { id: item.id, title: item.title, subtitle: item.subtitle, category: 'puzzle', subcategory: 'focus-draw', path: `/focusPages/focusDraw/focusDraw?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', }; }