feat: 首页增加每日练习模块
This commit is contained in:
@@ -33,6 +33,8 @@ const CUSTOM_MAX_WORDS = 11;
|
||||
const CHECKIN_MAX_WORDS = 8;
|
||||
const RANDOM_WORD_COUNT = 8;
|
||||
const CUSTOM_DEFAULT_WORDS = '东西南北日月山河风雨';
|
||||
/** 汉字每日打卡默认文案(8 字,与 CHECKIN_MAX_WORDS 一致) */
|
||||
const CHECKIN_DEFAULT_WORDS = '日拱一卒不期而至';
|
||||
const CUSTOM_CATEGORY_TAGS = WORDS.slice(0, 3).map((cat) => ({
|
||||
categoryId: cat.categoryId,
|
||||
icon: cat.icon,
|
||||
@@ -65,8 +67,7 @@ createPage(
|
||||
data: {
|
||||
pageTitle: HANDWRITING_SHEET_WORKSHEET_DEFINITIONS[0].title,
|
||||
functionId: HANDWRITING_SHEET_WORKSHEET_ID,
|
||||
currentMode:
|
||||
HANDWRITING_SHEET_WORKSHEET_ID as HandwritingSheetMode,
|
||||
currentMode: HANDWRITING_SHEET_WORKSHEET_ID as HandwritingSheetMode,
|
||||
modeOptions: HANDWRITING_SHEET_MODE_OPTIONS,
|
||||
hasContent: false,
|
||||
words: [] as string[],
|
||||
@@ -155,7 +156,7 @@ createPage(
|
||||
|
||||
async prepareCanvasForCurrentMode() {
|
||||
if (!this.canvas) return;
|
||||
if (this.data.currentMode === 'handwriting-sheet') {
|
||||
if (this.data.currentMode === 'hanzi-sheet') {
|
||||
if (!this.wordDrawService) return;
|
||||
await this.wordDrawService.drawLayout();
|
||||
const { maxRow, maxCol } =
|
||||
@@ -167,11 +168,8 @@ createPage(
|
||||
}
|
||||
},
|
||||
|
||||
applyMode(
|
||||
mode: HandwritingSheetMode,
|
||||
options?: { redraw?: boolean },
|
||||
) {
|
||||
const isCheckin = mode === 'handwriting-daily-checkin';
|
||||
applyMode(mode: HandwritingSheetMode, options?: { redraw?: boolean }) {
|
||||
const isCheckin = mode === 'hanzi-daily-checkin';
|
||||
const max = isCheckin ? CHECKIN_MAX_WORDS : CUSTOM_MAX_WORDS;
|
||||
|
||||
this.setData(
|
||||
@@ -253,7 +251,7 @@ createPage(
|
||||
},
|
||||
|
||||
getMaxWordsForMode(): number {
|
||||
return this.data.currentMode === 'handwriting-daily-checkin'
|
||||
return this.data.currentMode === 'hanzi-daily-checkin'
|
||||
? CHECKIN_MAX_WORDS
|
||||
: CUSTOM_MAX_WORDS;
|
||||
},
|
||||
@@ -375,8 +373,25 @@ createPage(
|
||||
},
|
||||
|
||||
initDefaultWords() {
|
||||
if (this.data.currentMode === 'handwriting-daily-checkin') {
|
||||
this.refreshWords();
|
||||
if (this.data.currentMode === 'hanzi-daily-checkin') {
|
||||
const defaults = this.getSupportedWords(
|
||||
this.splitToSingleChars(CHECKIN_DEFAULT_WORDS),
|
||||
).slice(0, CHECKIN_MAX_WORDS);
|
||||
|
||||
if (defaults.length === 0) {
|
||||
this.refreshWords();
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData(
|
||||
{
|
||||
words: defaults,
|
||||
inputWords: defaults,
|
||||
selectedWords: [],
|
||||
inputValue: defaults.join(''),
|
||||
},
|
||||
() => this.renderPracticeContent().catch(console.error),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -401,8 +416,7 @@ createPage(
|
||||
},
|
||||
|
||||
refreshWords() {
|
||||
const isCheckin =
|
||||
this.data.currentMode === 'handwriting-daily-checkin';
|
||||
const isCheckin = this.data.currentMode === 'hanzi-daily-checkin';
|
||||
const candidates = isCheckin
|
||||
? collectFirstGradeWords()
|
||||
: WORDS.slice(0, 3).reduce(
|
||||
@@ -446,7 +460,7 @@ createPage(
|
||||
|
||||
const words = this.data.words as string[];
|
||||
|
||||
if (this.data.currentMode === 'handwriting-daily-checkin') {
|
||||
if (this.data.currentMode === 'hanzi-daily-checkin') {
|
||||
await this.renderCheckinContent(words);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user