feat: 优化字帖功能

This commit is contained in:
R524809
2026-02-11 16:03:39 +08:00
parent 943250b34a
commit cbf07faf27
11 changed files with 474 additions and 280 deletions
+10 -22
View File
@@ -5,8 +5,7 @@ import {
IDrawService,
TemplateType,
} from '../../service/drawServiceFactory';
import { checkAndSaveImage } from '../../utils/saveImage';
import { shouldShowShareGuide } from '../../utils/shareGuide';
import { downloadPrint } from '../../utils/downloadPrint';
import tracker from '../../utils/tracker';
import { defaultShareConfig } from '../../config/config';
@@ -120,7 +119,7 @@ Page({
if (currentCardList.length > 0) {
this.drawService
.draw(currentCardList)
.catch((err) => {
.catch((err: any) => {
console.error('绘制失败:', err);
});
}
@@ -168,7 +167,7 @@ Page({
}
// 如果canvas已初始化且有内容,则绘制
if (this.drawService && updatedCardList!.length > 0) {
this.drawService.draw(updatedCardList!).catch((err) => {
this.drawService.draw(updatedCardList!).catch((err: any) => {
console.error('绘制失败:', err);
});
}
@@ -186,7 +185,7 @@ Page({
}
// 如果canvas已初始化且有内容,则绘制
if (this.drawService && currentCardList.length > 0) {
this.drawService.draw(currentCardList).catch((err) => {
this.drawService.draw(currentCardList).catch((err: any) => {
console.error('绘制失败:', err);
});
}
@@ -288,27 +287,16 @@ Page({
},
/** 下载打印 */
exportToPrint() {
async exportToPrint() {
if (!this.canvas || this.data.cardList.length <= 0) {
return;
}
// 检查是否需要显示分享引导
if (shouldShowShareGuide()) {
this.setData({ showShareDialog: true });
return;
}
// 上报下载埋点
tracker.reportDownload('涂色识字', this.data.selectedTemplate);
// 直接下载
checkAndSaveImage(this.canvas);
},
/** 关闭分享引导弹窗 */
onCloseShareDialog() {
this.setData({ showShareDialog: false });
await downloadPrint(this.canvas, {
errorToast: '请先生成涂色卡',
trackerName: '涂色识字',
trackerMode: this.data.selectedTemplate,
});
},
/** 分享成功回调(由组件触发) */