feat: 完成分龄页开发
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import type { DebugPublishMeta } from '../../utils/debugPublish';
|
||||
import { inferGradeFromAge } from '../../utils/debugPublish';
|
||||
|
||||
interface MathDrawDefinition {
|
||||
/** 本地 worksheet 元数据(与云库 `worksheets` 文档 `_id` 对齐,用于发布与批量同步脚本) */
|
||||
interface MathWorksheetDefinition {
|
||||
id: string;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
@@ -12,7 +13,7 @@ interface MathDrawDefinition {
|
||||
sortOrder: number;
|
||||
}
|
||||
|
||||
const MATH_DRAW_DEFINITIONS = [
|
||||
export const MATH_WORKSHEET_DEFINITIONS = [
|
||||
{
|
||||
id: 'number-find',
|
||||
title: '找数字,涂一涂',
|
||||
@@ -28,8 +29,8 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'number-write',
|
||||
title: '看数字,写一写',
|
||||
subtitle: '按笔画顺序书写数字',
|
||||
ageMin: 3,
|
||||
ageMax: 5,
|
||||
ageMin: 4,
|
||||
ageMax: 6,
|
||||
difficulty: 1,
|
||||
tags: ['数学', '数字书写', '描红'],
|
||||
sortOrder: 102,
|
||||
@@ -68,8 +69,8 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'number-object-fill',
|
||||
title: '数物填写',
|
||||
subtitle: '数出数量,填写对应数字',
|
||||
ageMin: 3,
|
||||
ageMax: 5,
|
||||
ageMin: 4,
|
||||
ageMax: 6,
|
||||
difficulty: 1,
|
||||
tags: ['数学', '数物对应', '填写'],
|
||||
sortOrder: 106,
|
||||
@@ -88,8 +89,8 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'counting-fill',
|
||||
title: '数一数,填一填',
|
||||
subtitle: '数出物品数量,填写数字',
|
||||
ageMin: 3,
|
||||
ageMax: 5,
|
||||
ageMin: 4,
|
||||
ageMax: 6,
|
||||
difficulty: 1,
|
||||
tags: ['数学', '计数', '填写'],
|
||||
sortOrder: 108,
|
||||
@@ -128,8 +129,8 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'number-decompose',
|
||||
title: '10以内数的分与合',
|
||||
subtitle: '把数字分一分,合一合',
|
||||
ageMin: 4,
|
||||
ageMax: 6,
|
||||
ageMin: 5,
|
||||
ageMax: 7,
|
||||
difficulty: 1,
|
||||
tags: ['数学', '分与合', '10以内'],
|
||||
sortOrder: 112,
|
||||
@@ -158,8 +159,8 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'addition-5',
|
||||
title: '5以内加法',
|
||||
subtitle: '图形化展示5以内加法',
|
||||
ageMin: 3,
|
||||
ageMax: 5,
|
||||
ageMin: 4,
|
||||
ageMax: 6,
|
||||
difficulty: 1,
|
||||
tags: ['数学', '加法', '5以内', '计算题'],
|
||||
sortOrder: 115,
|
||||
@@ -178,8 +179,8 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'subtraction-10',
|
||||
title: '10以内减法',
|
||||
subtitle: '图形化展示10以内减法',
|
||||
ageMin: 4,
|
||||
ageMax: 6,
|
||||
ageMin: 5,
|
||||
ageMax: 7,
|
||||
difficulty: 2,
|
||||
tags: ['数学', '减法', '10以内', '计算题'],
|
||||
sortOrder: 117,
|
||||
@@ -238,7 +239,7 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'practice-addition',
|
||||
title: '加法运算',
|
||||
subtitle: '10/20/50/100 以内加法',
|
||||
ageMin: 5,
|
||||
ageMin: 6,
|
||||
ageMax: 8,
|
||||
difficulty: 3,
|
||||
tags: ['数学', '口算', '加法', '计算题'],
|
||||
@@ -248,7 +249,7 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'practice-subtraction',
|
||||
title: '减法运算',
|
||||
subtitle: '10/20/50/100以内减法',
|
||||
ageMin: 5,
|
||||
ageMin: 6,
|
||||
ageMax: 8,
|
||||
difficulty: 3,
|
||||
tags: ['数学', '口算', '减法', '计算题'],
|
||||
@@ -258,7 +259,7 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'practice-mixed',
|
||||
title: '混合运算',
|
||||
subtitle: '10/20/50/100以内加减法混合',
|
||||
ageMin: 5,
|
||||
ageMin: 6,
|
||||
ageMax: 8,
|
||||
difficulty: 3,
|
||||
tags: ['数学', '口算', '加减法', '计算题'],
|
||||
@@ -268,19 +269,19 @@ const MATH_DRAW_DEFINITIONS = [
|
||||
id: 'multiplication-table',
|
||||
title: '九九乘法表',
|
||||
subtitle: '学习九九乘法口诀',
|
||||
ageMin: 6,
|
||||
ageMin: 7,
|
||||
ageMax: 8,
|
||||
difficulty: 3,
|
||||
tags: ['数学', '乘法', '九九乘法表'],
|
||||
sortOrder: 126,
|
||||
},
|
||||
] as const satisfies ReadonlyArray<MathDrawDefinition>;
|
||||
] as const satisfies ReadonlyArray<MathWorksheetDefinition>;
|
||||
|
||||
type MathDrawDefinitionItem = (typeof MATH_DRAW_DEFINITIONS)[number];
|
||||
type MathWorksheetDefinitionItem = (typeof MATH_WORKSHEET_DEFINITIONS)[number];
|
||||
|
||||
const MATH_DRAW_BY_ID = Object.fromEntries(
|
||||
MATH_DRAW_DEFINITIONS.map((item) => [item.id, item]),
|
||||
) as Record<string, MathDrawDefinitionItem>;
|
||||
const MATH_WORKSHEET_BY_ID = Object.fromEntries(
|
||||
MATH_WORKSHEET_DEFINITIONS.map((item) => [item.id, item]),
|
||||
) as Record<string, MathWorksheetDefinitionItem>;
|
||||
|
||||
function resolveMathPublishId(
|
||||
routeId: string,
|
||||
@@ -295,7 +296,7 @@ function resolveMathPublishId(
|
||||
return 'number-object-fill';
|
||||
}
|
||||
|
||||
if (routeId in MATH_DRAW_BY_ID) {
|
||||
if (routeId in MATH_WORKSHEET_BY_ID) {
|
||||
return routeId;
|
||||
}
|
||||
|
||||
@@ -308,7 +309,7 @@ export function getPublishMetaByMathState(
|
||||
mode?: string,
|
||||
): DebugPublishMeta | null {
|
||||
const id = resolveMathPublishId(routeId, selectedTypeId, mode);
|
||||
const item = MATH_DRAW_BY_ID[id];
|
||||
const item = MATH_WORKSHEET_BY_ID[id];
|
||||
if (!item) return null;
|
||||
|
||||
return {
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from './registry';
|
||||
import { getPublishMetaByMathState } from './mathDraw.config';
|
||||
import type { DebugPublishMeta } from '../../utils/debugPublish';
|
||||
import { incrementWorksheetLikes } from '../../utils/worksheetStats';
|
||||
|
||||
const TYPE_LIST = MATH_TYPE_CONFIGS.map((t) => ({
|
||||
id: t.id,
|
||||
@@ -130,6 +131,7 @@ createMathPage({
|
||||
selectedTypeId: id,
|
||||
functionId: id,
|
||||
pageTitle: title,
|
||||
isPreviewFavorite: false,
|
||||
showActions: !!typeConfig.actions,
|
||||
currentActions: typeConfig.actions || [],
|
||||
actionsTitle: typeConfig.actionsTitle || '选择模式',
|
||||
@@ -170,6 +172,7 @@ createMathPage({
|
||||
this.setData({
|
||||
currentMode: value,
|
||||
pageTitle: title,
|
||||
isPreviewFavorite: false,
|
||||
});
|
||||
|
||||
this.initPageInfo(this.data.functionId, title);
|
||||
@@ -260,15 +263,28 @@ createMathPage({
|
||||
this.onRandom();
|
||||
},
|
||||
|
||||
onPreviewFavorite() {
|
||||
async onPreviewFavorite() {
|
||||
const next = !this.data.isPreviewFavorite;
|
||||
this.setData({ isPreviewFavorite: next });
|
||||
if (next) {
|
||||
const id = this.getWorksheetStatsId();
|
||||
if (id) incrementWorksheetLikes(id);
|
||||
}
|
||||
wx.showToast({
|
||||
title: next ? '收藏成功' : '已取消收藏',
|
||||
icon: 'none',
|
||||
});
|
||||
},
|
||||
|
||||
getWorksheetStatsId(): string {
|
||||
const meta = getPublishMetaByMathState(
|
||||
this.data.functionId,
|
||||
this.data.selectedTypeId,
|
||||
this.data.currentMode,
|
||||
);
|
||||
return meta?.id || this.data.functionId;
|
||||
},
|
||||
|
||||
getPublishMeta(): DebugPublishMeta {
|
||||
const meta = getPublishMetaByMathState(
|
||||
this.data.functionId,
|
||||
|
||||
Reference in New Issue
Block a user