feat:架构代码优化

This commit is contained in:
R524809
2025-12-11 13:02:44 +08:00
parent 2c32235568
commit 3c0e2af10d
89 changed files with 2774 additions and 2816 deletions
@@ -0,0 +1,73 @@
import { BaseDrawService } from '../../../service/baseDraw';
import { drawCountingSelectContent } from './countingSelectContentDraw';
/**
* 数一数选一选/填一填绘制服务
* 组合使用基础绘制服务和内容区域绘制服务
* 支持两种模式:'select'(选一选)和 'fill'(填一填)
*/
class CountingSelectDraw extends BaseDrawService {
countingData: {
problems: Array<{
count: number;
imageIndex: number;
imageType: 'fruits' | 'twelve-animals';
options?: number[];
correctIndex?: number;
}>;
} | null;
mode: 'select' | 'fill';
constructor(
canvas: Canvas,
ctx: RenderingContext,
options?: Record<string, any>,
) {
super(canvas, ctx, options);
this.countingData = null;
this.mode = 'select'; // 默认选一选模式
}
async draw(
countingData: {
problems: Array<{
count: number;
imageIndex: number;
imageType: 'fruits' | 'twelve-animals';
options?: number[];
correctIndex?: number;
}>;
},
mode: 'select' | 'fill' = 'select',
) {
if (!countingData || !countingData.problems) {
return;
}
this.setPrintConfig();
this.countingData = countingData;
this.mode = mode;
this.clear();
this.setPaper();
// 绘制Header
if (this.headerType !== 'minimal') {
await this.drawHeader();
} else {
this.drawMiniHeader();
}
// 绘制内容区域
this.drawDivider();
await drawCountingSelectContent({
canvas: this.canvas,
ctx: this.ctx,
countingData: this.countingData,
mode: this.mode,
canvasWidth: this.canvasWidth,
startY: this.currentY,
});
}
}
export default CountingSelectDraw;