feat: 汉字每日打卡页面优化
This commit is contained in:
@@ -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 [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user