feat: 更新内容管理方案

This commit is contained in:
R524809
2026-04-29 17:47:14 +08:00
parent 63fa08ff1a
commit 2cb9ec55d6
44 changed files with 1181 additions and 625 deletions
@@ -0,0 +1,331 @@
import type { DebugPublishMeta } from '../../utils/debugPublish';
import { inferGradeFromAge } from '../../utils/debugPublish';
interface MathDrawDefinition {
id: string;
title: string;
subtitle: string;
ageMin: number;
ageMax: number;
difficulty: 1 | 2 | 3 | 4;
tags: string[];
sortOrder: number;
}
const MATH_DRAW_DEFINITIONS = [
{
id: 'number-find',
title: '找数字,涂一涂',
subtitle: '在数字方阵中找出目标数字并涂色',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '数字认知', '涂色'],
sortOrder: 101,
},
{
id: 'number-write',
title: '看数字,写一写',
subtitle: '按笔画顺序练习书写数字',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '数字书写', '描红'],
sortOrder: 102,
},
{
id: 'number-coloring',
title: '按数字,涂颜色',
subtitle: '按指定数字给对应圆圈涂色',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '数字认知', '涂色'],
sortOrder: 103,
},
{
id: 'counting-matching',
title: '数一数,连一连',
subtitle: '连线配对数字和对应数量图形',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '计数', '连线'],
sortOrder: 104,
},
{
id: 'number-object-match',
title: '数物连线',
subtitle: '连线相同数量的物品和数字',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '数物对应', '连线'],
sortOrder: 105,
},
{
id: 'number-object-fill',
title: '数物填写',
subtitle: '数物品数量,填写对应数字',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '数物对应', '填写'],
sortOrder: 106,
},
{
id: 'counting-select',
title: '数一数,选一选',
subtitle: '数出物品数量,圈出正确答案',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '计数', '选择'],
sortOrder: 107,
},
{
id: 'counting-fill',
title: '数一数,填一填',
subtitle: '数出物品数量,填写数字',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '计数', '填写'],
sortOrder: 108,
},
{
id: 'compare',
title: '数一数,比大小',
subtitle: '比较数量,填入 ><=',
ageMin: 4,
ageMax: 6,
difficulty: 2,
tags: ['数学', '比较', '数量'],
sortOrder: 109,
},
{
id: 'number-sort',
title: '数字排序',
subtitle: '写出正确的数字顺序',
ageMin: 4,
ageMax: 6,
difficulty: 2,
tags: ['数学', '数字排序', '序列'],
sortOrder: 110,
},
{
id: 'missing-number',
title: '填上缺少的数字',
subtitle: '在数列中找出并填写缺失数字',
ageMin: 4,
ageMax: 6,
difficulty: 2,
tags: ['数学', '数字序列', '填写'],
sortOrder: 111,
},
{
id: 'number-decompose',
title: '10以内数的分与合',
subtitle: '把数字分一分,合一合',
ageMin: 4,
ageMax: 6,
difficulty: 1,
tags: ['数学', '分与合', '10以内'],
sortOrder: 112,
},
{
id: 'number-decompose-20',
title: '20以内数的分与合',
subtitle: '把数字分一分,合一合',
ageMin: 5,
ageMax: 7,
difficulty: 2,
tags: ['数学', '分与合', '20以内'],
sortOrder: 113,
},
{
id: 'one-digit-addition',
title: '一位数加法',
subtitle: '通过圆点学习一位数加法运算',
ageMin: 4,
ageMax: 6,
difficulty: 2,
tags: ['数学', '加法', '一位数'],
sortOrder: 114,
},
{
id: 'addition-5',
title: '5以内加法',
subtitle: '图形化展示 5 以内加法',
ageMin: 3,
ageMax: 5,
difficulty: 1,
tags: ['数学', '加法', '5以内', '计算题'],
sortOrder: 115,
},
{
id: 'addition-10',
title: '10以内加法',
subtitle: '图形化展示 10 以内加法',
ageMin: 4,
ageMax: 6,
difficulty: 2,
tags: ['数学', '加法', '10以内', '计算题'],
sortOrder: 116,
},
{
id: 'subtraction-10',
title: '10以内减法',
subtitle: '图形化展示 10 以内减法',
ageMin: 4,
ageMax: 6,
difficulty: 2,
tags: ['数学', '减法', '10以内', '计算题'],
sortOrder: 117,
},
{
id: 'addition-subtraction-10',
title: '10以内加减法',
subtitle: '加减法混合运算',
ageMin: 5,
ageMax: 7,
difficulty: 2,
tags: ['数学', '加减法', '10以内', '计算题'],
sortOrder: 118,
},
{
id: 'make-ten',
title: '凑十法练习',
subtitle: '20 以内进位加法',
ageMin: 5,
ageMax: 7,
difficulty: 3,
tags: ['数学', '凑十法', '进位加法', '计算题'],
sortOrder: 119,
},
{
id: 'break-ten',
title: '破十法练习',
subtitle: '20 以内退位减法',
ageMin: 5,
ageMax: 7,
difficulty: 3,
tags: ['数学', '破十法', '退位减法', '计算题'],
sortOrder: 120,
},
{
id: 'flat-ten',
title: '平十法练习',
subtitle: '20 以内退位减法',
ageMin: 5,
ageMax: 7,
difficulty: 3,
tags: ['数学', '平十法', '退位减法', '计算题'],
sortOrder: 121,
},
{
id: 'borrow-ten',
title: '借十法练习',
subtitle: '20 以上退位减法',
ageMin: 6,
ageMax: 8,
difficulty: 4,
tags: ['数学', '借十法', '退位减法', '计算题'],
sortOrder: 122,
},
{
id: 'practice-addition',
title: '加法运算',
subtitle: '10/20/50/100 以内加法',
ageMin: 5,
ageMax: 8,
difficulty: 3,
tags: ['数学', '口算', '加法', '计算题'],
sortOrder: 123,
},
{
id: 'practice-subtraction',
title: '减法运算',
subtitle: '10/20/50/100 以内减法',
ageMin: 5,
ageMax: 8,
difficulty: 3,
tags: ['数学', '口算', '减法', '计算题'],
sortOrder: 124,
},
{
id: 'practice-mixed',
title: '混合运算',
subtitle: '10/20/50/100 以内加减法混合',
ageMin: 5,
ageMax: 8,
difficulty: 3,
tags: ['数学', '口算', '加减法', '计算题'],
sortOrder: 125,
},
{
id: 'multiplication-table',
title: '九九乘法表',
subtitle: '学习九九乘法口诀',
ageMin: 6,
ageMax: 8,
difficulty: 3,
tags: ['数学', '乘法', '九九乘法表'],
sortOrder: 126,
},
] as const satisfies ReadonlyArray<MathDrawDefinition>;
type MathDrawDefinitionItem = (typeof MATH_DRAW_DEFINITIONS)[number];
const MATH_DRAW_BY_ID = Object.fromEntries(
MATH_DRAW_DEFINITIONS.map((item) => [item.id, item]),
) as Record<string, MathDrawDefinitionItem>;
function resolveMathPublishId(
routeId: string,
selectedTypeId: string,
mode?: string,
): string {
if (selectedTypeId === 'addition') {
return mode || 'addition-5';
}
if (selectedTypeId === 'number-object-match' && mode === 'fill') {
return 'number-object-fill';
}
if (routeId in MATH_DRAW_BY_ID) {
return routeId;
}
return selectedTypeId;
}
export function getPublishMetaByMathState(
routeId: string,
selectedTypeId: string,
mode?: string,
): DebugPublishMeta | null {
const id = resolveMathPublishId(routeId, selectedTypeId, mode);
const item = MATH_DRAW_BY_ID[id];
if (!item) return null;
return {
id: item.id,
title: item.title,
subtitle: item.subtitle,
category: 'math',
subcategory: 'math-draw',
path: `/mathPages/mathDraw/mathDraw?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',
};
}