Files
doodle-mini/miniprogram/pinyinPages/pinyinDictation/draw/pinyinDictationDraw.ts
T
2026-05-20 15:33:06 +08:00

34 lines
1.0 KiB
TypeScript

import { BaseDrawService } from '../../../core/draw/baseDraw';
import type { PinyinDictationMode } from '../pinyinDictation.config';
import PinyinDictationSheetDraw from './PinyinDictationSheetDraw';
import PinyinDailyDraw from './PinyinDailyDraw';
export interface PinyinDictationData {
mode: PinyinDictationMode;
dayIndex?: number;
}
/**
* 拼音听写/描红绘制分发层。
* 根据 data.mode 委托给对应的独立 DrawService 完成实际绘制。
*/
export default class PinyinDictationDraw extends BaseDrawService {
async draw(data: PinyinDictationData) {
if (data.mode === 'pinyin-daily') {
const delegate = new PinyinDailyDraw(
this.canvas,
this.ctx,
this.options,
);
await delegate.draw(data.dayIndex ?? 0);
} else {
const delegate = new PinyinDictationSheetDraw(
this.canvas,
this.ctx,
this.options,
);
await delegate.draw(data);
}
}
}