feat: 汉字每日打卡页面优化

This commit is contained in:
R524809
2026-05-22 11:00:04 +08:00
parent 41082f59ef
commit bcece55238
7 changed files with 95 additions and 27 deletions
+19
View File
@@ -255,3 +255,22 @@ export const WORDS = [
words: ['个', '只', '匹', '条', '朵', '棵', '片', '张', '本', '杯', '块', '双'],
},
];
/** 将 categoryId 转为 word-picker / van-tabs 使用的数组下标 */
export function getCategoryTabIndex(categoryId: number): number {
const index = WORDS.findIndex((cat) => cat.categoryId === categoryId);
return index >= 0 ? index : 0;
}
/** 汇总分类下全部汉字(含一二年级 sections) */
export function collectCategoryWords(
cat: (typeof WORDS)[number],
): string[] {
if (cat.words?.length) {
return cat.words;
}
if (cat.sections?.length) {
return cat.sections.flatMap((section) => section.words);
}
return [];
}