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
+17 -2
View File
@@ -35,6 +35,7 @@ createFocusPage({
actionsTitle: '选择模式',
currentActions: [] as FocusTypeAction[],
currentMode: '',
isPreviewFavorite: false,
},
onLoad(options: { id?: string; mode?: string }) {
@@ -65,13 +66,13 @@ createFocusPage({
this.initPageInfo(routeId, title);
},
onReady() {
onCanvasReady(e: WechatMiniprogram.CustomEvent) {
if (!this.currentTypeConfig) return;
const typeConfig = this.currentTypeConfig;
const mode = this.data.currentMode;
this.initCanvas({
this.initCanvasFromComponent(e.detail, {
createDrawService: (
canvas: Canvas,
ctx: RenderingContext,
@@ -181,4 +182,18 @@ createFocusPage({
);
this.drawCanvas();
},
/** 打印预览角标:换一批,与「随机生成」相同逻辑 */
onPreviewRefresh() {
this.onRandom();
},
onPreviewFavorite() {
const next = !this.data.isPreviewFavorite;
this.setData({ isPreviewFavorite: next });
wx.showToast({
title: next ? '收藏成功' : '已取消收藏',
icon: 'none',
});
},
});