feat: 绘制基础类重构

This commit is contained in:
R524809
2026-04-10 15:06:11 +08:00
parent a911da6181
commit e74fd3709c
17 changed files with 1091 additions and 278 deletions
+15 -9
View File
@@ -1,3 +1,13 @@
/**
* 田字格练字服务
* 根据汉字列表绘制到Canvas
*
* 支持的汉字类型:
* - character:汉字
* - number:数字
* - letter:字母
* - symbol:符号
*/
import { BaseDrawService } from '../core/draw/baseDraw';
import { CharacterItem } from '../types/characterType';
@@ -255,32 +265,28 @@ class WordDrawService extends BaseDrawService {
this.clear();
this.setPaper();
// 绘制Header
if (this.headerType !== 'minimal') {
await this.drawHeader();
} else {
this.drawMiniHeader();
}
await this.drawHeader();
this.drawDivider();
this.drawContentEmpty();
await this.drawContentEmpty();
}
async drawContentEmpty() {
this.clearContentArea();
this.drawContent(null);
await this.drawPrintFooter();
}
/**
* 绘制田字格和练字内容
* @param wordsMap 形如 { "其": ["M.. L.. Z", ...], ... },不超过 10 个汉字
*/
drawPracticeContent(characters: CharacterItem[]) {
async drawPracticeContent(characters: CharacterItem[]) {
// 清空内容区域(页眉以下的部分)
this.clearContentArea();
// 绘制田字格和练字内容
this.drawContent(characters);
await this.drawPrintFooter();
}
/**