feat: 拼音描红和默写一

This commit is contained in:
R524809
2026-05-20 10:18:25 +08:00
parent b70e54d6b0
commit cab4e9c33f
5 changed files with 23 additions and 20 deletions
@@ -48,7 +48,7 @@ Component({
formSubtitle: '',
formTags: '',
formStatus: 'draft',
formCropMode: 'header-footer',
formCropMode: 'header-only', // header-only | header-footer | none
formQuality: DEBUG_PUBLISH_DEFAULT_QUALITY,
formWidth: DEBUG_PUBLISH_DEFAULT_WIDTH,
maxSizeKB: DEBUG_PUBLISH_MAX_SIZE_KB,
@@ -83,7 +83,7 @@ Component({
formSubtitle: meta?.subtitle ?? '',
formTags: meta?.tags?.join(', ') ?? '',
formStatus: meta?.status ?? 'draft',
formCropMode: 'header-footer',
formCropMode: 'header-only', // 默认裁剪头部
formQuality: DEBUG_PUBLISH_DEFAULT_QUALITY,
formWidth: DEBUG_PUBLISH_DEFAULT_WIDTH,
});
@@ -19,7 +19,7 @@ export const PINYIN_DICTATION_WORKSHEET_DEFINITIONS = [
{
id: 'pinyin-tracing',
icon: 'draw-o',
title: '描红练习',
title: '拼音描红练习',
subtitle: '跟着描红学拼音字母',
ageMin: 5,
ageMax: 7,
@@ -30,7 +30,7 @@ export const PINYIN_DICTATION_WORKSHEET_DEFINITIONS = [
{
id: 'pinyin-dictation',
icon: 'start-a',
title: '默写练习',
title: '拼音默写练习',
subtitle: '空白格子默写拼音字母',
ageMin: 6,
ageMax: 8,
@@ -106,7 +106,7 @@ createPage(
const next = !this.data.isPreviewFavorite;
this.setData({ isPreviewFavorite: next });
const id = this.data.worksheetId;
if (id) {
if (id && this._favoritedMap) {
this._favoritedMap[id] = next;
if (next) {
addFavorite(id);
@@ -124,7 +124,7 @@ createPage(
const ids = PINYIN_DICTATION_MODE_OPTIONS.map((d) => d.id);
this._favoritedMap = await batchCheckFavorited(ids);
const currentId = this.data.worksheetId;
if (this._favoritedMap[currentId]) {
if (this._favoritedMap?.[currentId]) {
this.setData({ isPreviewFavorite: true });
}
},
@@ -145,7 +145,7 @@ createPage(
worksheetId,
functionId: worksheetId,
currentMode: worksheetId as PinyinDictationMode,
isPreviewFavorite: !!this._favoritedMap[worksheetId],
isPreviewFavorite: !!this._favoritedMap?.[worksheetId],
},
() => {
this.initPageInfo(worksheetId, '拼音字母默写');
@@ -1,4 +1,8 @@
import { MOCK_SEED_COUNTS } from './mockLikes';
import { MATH_WORKSHEET_DEFINITIONS } from '../../mathPages/mathDraw/mathDraw.config';
import { FOCUS_WORKSHEET_DEFINITIONS } from '../../focusPages/focusDraw/focusDraw.config';
import { LETTER_TRACING_WORKSHEET_DEFINITIONS } from '../../englishPages/letterTracing/letterTracing.config';
import { PINYIN_DICTATION_MODE_OPTIONS } from '../../pinyinPages/pinyinDictation/pinyinDictation.config';
type CloudFunctionResult<T> = {
success?: boolean;
@@ -47,29 +51,28 @@ function inferGradeFromAge(ageMin: number, ageMax: number): number {
return ageGradeMap[centerAge] ?? 0;
}
type ConfigModule = Record<string, readonly LocalDef[] | unknown>;
type ConfigSource = {
label: string;
modulePath: string;
exportName: string;
data: readonly LocalDef[];
};
const CONFIG_SOURCES: ConfigSource[] = [
{
label: 'math',
modulePath: '../../mathPages/mathDraw/mathDraw.config',
exportName: 'MATH_WORKSHEET_DEFINITIONS',
data: MATH_WORKSHEET_DEFINITIONS as unknown as LocalDef[],
},
{
label: 'focus',
modulePath: '../../focusPages/focusDraw/focusDraw.config',
exportName: 'FOCUS_WORKSHEET_DEFINITIONS',
data: FOCUS_WORKSHEET_DEFINITIONS as unknown as LocalDef[],
},
{
label: 'letterTracing',
modulePath: '../../englishPages/letterTracing/letterTracing.config',
exportName: 'LETTER_TRACING_WORKSHEET_DEFINITIONS',
data: LETTER_TRACING_WORKSHEET_DEFINITIONS as unknown as LocalDef[],
},
{
label: 'pinyin',
data: PINYIN_DICTATION_MODE_OPTIONS as unknown as LocalDef[],
},
];
@@ -85,8 +88,7 @@ function isLocalDef(value: unknown): value is LocalDef {
}
async function loadConfigSource(source: ConfigSource): Promise<LocalDef[]> {
const mod = (await require.async(source.modulePath)) as ConfigModule;
const rows = mod[source.exportName];
const rows = source.data;
if (!Array.isArray(rows) || !rows.every(isLocalDef)) {
throw new Error(`${source.label} 配置格式不正确`);
+3 -2
View File
@@ -69,7 +69,7 @@ export async function getFavoriteList(
data: { action: 'list', page, pageSize },
});
const result = (res?.result as any) || {};
return result.code === 0 ? result.data : [];
return result.code === 0 ? result.data || [] : [];
} catch (e) {
console.error('getFavoriteList failed', e);
return [];
@@ -126,9 +126,10 @@ export async function batchCheckFavorited(
data: { action: 'batchCheck', worksheetIds },
});
const result = (res?.result as any) || {};
return result.code === 0 ? result.data : {};
return result.code === 0 ? result.data || {} : {};
} catch (e) {
console.error('batchCheckFavorited failed', e);
return {};
}
}