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 [];
}
+24 -1
View File
@@ -113,10 +113,11 @@ export class BaseDrawService {
}
/**
* 暂未使用
* 页脚:顶部分割线 + 居中 `doodle-footer.png`(小鸭与「涂鸦丫」品牌图)。
* 图片底边与纸张底边留白对齐,便于「探头」视觉。请在整页正文绘制完成后调用,避免被内容覆盖。
*/
async drawPrintFooter(): Promise<void> {
async drawPrintImageFooter(): Promise<void> {
const { ctx, canvasWidth, canvasHeight } = this;
const margin = 24;
const bottomMargin = 2;
@@ -172,6 +173,28 @@ export class BaseDrawService {
}
}
/**
* 页脚:页面底部居中绘制品牌文案「涂鸦丫小程序」(粗体)。
* 请在整页正文绘制完成后调用,避免被内容覆盖。
*/
async drawPrintFooter(): Promise<void> {
const { ctx, canvasWidth, canvasHeight } = this;
const text = '涂鸦丫小程序';
const bottomMargin = 12;
const fontSize = 13;
const font = `bold ${fontSize}px "Microsoft Yahei", sans-serif`;
const textColor = '#7C766A';
ctx.save();
ctx.font = font;
ctx.fillStyle = textColor;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
const y = canvasHeight - bottomMargin - fontSize / 2;
ctx.fillText(text, canvasWidth / 2, y);
ctx.restore();
}
/**
* 绘制分割线(逻辑像素,尺寸除以3)
*/