feat: 打印预览组件化

This commit is contained in:
R524809
2026-04-22 15:02:48 +08:00
parent 4ad387e99d
commit de74666c9f
24 changed files with 552 additions and 273 deletions
+41
View File
@@ -168,6 +168,47 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) {
.exec();
},
/**
* 从 preview-card 组件的 canvas-ready 事件初始化 Canvas
* 用于已将 canvas 节点下沉到 preview-card 组件的页面
*/
initCanvasFromComponent(
this: PageCanvasInstance,
detail: {
canvas: Canvas;
ctx: RenderingContext;
width: number;
height: number;
},
options: InitCanvasOptions,
) {
this.canvas = detail.canvas;
this.ctx = detail.ctx;
this.boxWidth = detail.width;
this.boxHeight = detail.height;
this.setData({
boxWidth: detail.width,
boxHeight: detail.height,
});
const drawServiceOptions = {
title: this.data.pageTitle,
subTitle: this.data.subTitle || '',
...options.drawServiceOptions,
};
this.drawService = options.createDrawService(
detail.canvas,
detail.ctx,
drawServiceOptions,
);
if (options.onCanvasReady) {
options.onCanvasReady.call(this);
}
},
/**
* 导出打印
*/