feat: 开发完成拼音每日一练
This commit is contained in:
@@ -17,9 +17,12 @@ import {
|
||||
} from '../../utils/favorites';
|
||||
import { loadFontFace } from '../../core/font/fontLoader';
|
||||
import { TONEOZ_PINYIN } from '../../core/font/fontProfiles';
|
||||
import { buildPinyinDailyPickerItems } from '../shared/pinyinDailyData';
|
||||
|
||||
const pageInfoLookup = getModeInfo;
|
||||
|
||||
const DAILY_GROUPS = buildPinyinDailyPickerItems();
|
||||
|
||||
type PageData = CanvasDataState & {
|
||||
worksheetId: string;
|
||||
currentMode: PinyinDictationMode;
|
||||
@@ -29,6 +32,9 @@ type PageData = CanvasDataState & {
|
||||
debugPublishVisible: boolean;
|
||||
debugPublishLoading: boolean;
|
||||
debugPublishMeta: DebugPublishMeta | null;
|
||||
showDailyGroupPicker: boolean;
|
||||
dailyGroups: typeof DAILY_GROUPS;
|
||||
selectedDailyGroupIdx: number;
|
||||
};
|
||||
|
||||
createPage(
|
||||
@@ -53,6 +59,9 @@ createPage(
|
||||
debugPublishVisible: false,
|
||||
debugPublishLoading: false,
|
||||
debugPublishMeta: null,
|
||||
showDailyGroupPicker: false,
|
||||
dailyGroups: DAILY_GROUPS,
|
||||
selectedDailyGroupIdx: 0,
|
||||
} as unknown as PageData,
|
||||
|
||||
onLoad(options: { id?: string }) {
|
||||
@@ -93,6 +102,7 @@ createPage(
|
||||
await loadFontFace(TONEOZ_PINYIN);
|
||||
const data: PinyinDictationData = {
|
||||
mode: this.data.currentMode,
|
||||
dayIndex: this.data.selectedDailyGroupIdx,
|
||||
};
|
||||
await (this.drawService as PinyinDictationDraw).draw(data);
|
||||
this.setData({ hasContent: true });
|
||||
@@ -102,6 +112,26 @@ createPage(
|
||||
}
|
||||
},
|
||||
|
||||
onPreviewRefresh() {
|
||||
if (this.data.currentMode === 'pinyin-daily') {
|
||||
const total = DAILY_GROUPS.length;
|
||||
// 随机到不同的组
|
||||
let next = Math.floor(Math.random() * total);
|
||||
if (total > 1 && next === this.data.selectedDailyGroupIdx) {
|
||||
next = (next + 1) % total;
|
||||
}
|
||||
this.setData({ selectedDailyGroupIdx: next });
|
||||
}
|
||||
this.drawCanvas();
|
||||
},
|
||||
|
||||
onSelectDailyGroup(e: WechatMiniprogram.TouchEvent) {
|
||||
const idx = Number(e.currentTarget.dataset.idx);
|
||||
if (isNaN(idx) || idx === this.data.selectedDailyGroupIdx) return;
|
||||
this.setData({ selectedDailyGroupIdx: idx });
|
||||
this.drawCanvas();
|
||||
},
|
||||
|
||||
async onPreviewFavorite() {
|
||||
const next = !this.data.isPreviewFavorite;
|
||||
this.setData({ isPreviewFavorite: next });
|
||||
@@ -140,12 +170,15 @@ createPage(
|
||||
applyWorksheet(worksheetId: string, options?: { redraw?: boolean }) {
|
||||
if (!isValidMode(worksheetId)) return;
|
||||
|
||||
const isDaily = worksheetId === 'pinyin-daily';
|
||||
|
||||
this.setData(
|
||||
{
|
||||
worksheetId,
|
||||
functionId: worksheetId,
|
||||
currentMode: worksheetId as PinyinDictationMode,
|
||||
isPreviewFavorite: !!this._favoritedMap?.[worksheetId],
|
||||
showDailyGroupPicker: isDaily,
|
||||
},
|
||||
() => {
|
||||
this.initPageInfo(worksheetId, '拼音字母默写');
|
||||
|
||||
Reference in New Issue
Block a user