|
|
@@ -304,7 +304,8 @@
|
|
|
url: img.imgUrl,
|
|
|
name: img.name,
|
|
|
version: img.version,
|
|
|
- imgId: type == 'public' ? img.id : ''
|
|
|
+ imgId: type == 'public' ? img.id : '',
|
|
|
+ sealType: type // 传递签章类型
|
|
|
};
|
|
|
e.dataTransfer.setData('imageData', JSON.stringify(data));
|
|
|
e.dataTransfer.effectAllowed = 'copy';
|
|
|
@@ -330,9 +331,16 @@
|
|
|
img.onload = () => {
|
|
|
console.log('图片加载成功,原始尺寸:', img.width, img.height);
|
|
|
|
|
|
- // 使用图片原始尺寸
|
|
|
- const width = img.width;
|
|
|
- const height = img.height;
|
|
|
+ // 根据签章类型设置尺寸:公用章 120x120,个人章 120x40
|
|
|
+ let width, height;
|
|
|
+ if (data.sealType === 'private') {
|
|
|
+ width = 120;
|
|
|
+ height = 40;
|
|
|
+ } else {
|
|
|
+ width = 120;
|
|
|
+ height = 120;
|
|
|
+ }
|
|
|
+
|
|
|
const posX = x - width / 2;
|
|
|
const posY = y - height / 2;
|
|
|
|
|
|
@@ -355,7 +363,8 @@
|
|
|
width,
|
|
|
height,
|
|
|
originalWidth: img.width,
|
|
|
- originalHeight: img.height
|
|
|
+ originalHeight: img.height,
|
|
|
+ sealType: data.sealType
|
|
|
});
|
|
|
|
|
|
console.log('已添加的图片数量:', this.droppedImages.length);
|
|
|
@@ -793,7 +802,7 @@
|
|
|
},
|
|
|
|
|
|
// 渲染Canvas核心函数
|
|
|
- async renderToCanvas() {
|
|
|
+ async renderToCanvas(type) {
|
|
|
const targetElement = document.getElementById('captureTarget');
|
|
|
if (!targetElement) {
|
|
|
console.warn('未找到目标元素');
|
|
|
@@ -852,7 +861,11 @@
|
|
|
this.canvasGenerated = true;
|
|
|
|
|
|
// 设置 Canvas 拖放区域和事件监听
|
|
|
- this.setupCanvasDropZone();
|
|
|
+ if (type == 'init') {
|
|
|
+ this.setupCanvasDropZone();
|
|
|
+ } else {
|
|
|
+ this.redrawCanvas();
|
|
|
+ }
|
|
|
|
|
|
// 显示成功提示
|
|
|
// this.showMessage('✅ 渲染成功!可下载图片', 'success');
|
|
|
@@ -994,14 +1007,12 @@
|
|
|
this.droppedImages = data.droppedImages;
|
|
|
this.editableHtml = html;
|
|
|
this.$nextTick(() => {
|
|
|
- setTimeout(() => {
|
|
|
- this.redrawCanvas();
|
|
|
- }, 10000);
|
|
|
+ this.renderToCanvas();
|
|
|
});
|
|
|
} else {
|
|
|
this.editableHtml = html;
|
|
|
this.$nextTick(() => {
|
|
|
- this.renderToCanvas();
|
|
|
+ this.renderToCanvas('init');
|
|
|
});
|
|
|
}
|
|
|
}
|