feat: 打印预览组件化
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 导出打印
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user