From 7af7bde3f3bc3f5f1f72c9a11c05f3470b9dcd1f Mon Sep 17 00:00:00 2001 From: X1627315083 <1627315083@qq.com> Date: Tue, 27 Feb 2024 15:45:25 +0800 Subject: [PATCH] fix --- src/component/HomePage/ExportModel.vue | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/component/HomePage/ExportModel.vue b/src/component/HomePage/ExportModel.vue index d1e1c1ae..a617ecc6 100644 --- a/src/component/HomePage/ExportModel.vue +++ b/src/component/HomePage/ExportModel.vue @@ -123,8 +123,7 @@ export default defineComponent({ for (const [allItemIndex, allItem] of allBoardData.value[key].entries()) { await new Promise((resolve,reject)=>{ if(key == 'colorBoards'){ - position.x = 0 - position.y += position.height + var text = new fabric.Text(allItem.tcx, { left: 0, top: 60, @@ -141,16 +140,21 @@ export default defineComponent({ fontFamily: 'Arial', textAlign: "left", }); + let width = 110>text1.width?110:text1.width var color = new fabric.Rect({ - width: 130>text1.width?130:text1.width, + width: width, height: 60, textAlign: "left", - fill: `rgb(${allItem.r},${allItem.g},${allItem.b})`, + fill: `rgb(${allItem.rgbValue.r},${allItem.rgbValue.g},${allItem.rgbValue.b})`, }); + if((position.x+width > canvasWH.value.width) || (oldKey != key)){ + position.x = 0 + position.y += position.height + } var group = new fabric.Group([color, text, text1], { left: position.x, top: position.y, - width:130, + width:width, fill:'rgb(255,255,255)', cornerSize: 10, // 选中时,角的大小为20 transparentCorners: false, // 选中时,角是被填充了。true 空心;false 实心 @@ -159,6 +163,8 @@ export default defineComponent({ }); // 将矩形对象添加到 canvas 中 canvas.add(group); + oldKey = key + position.x += width + margin position.height = group.height+margin resolve() }else{ @@ -184,9 +190,10 @@ export default defineComponent({ // lockRotation:true, // lockScalingX:true, lockRotation:true, + crossOrigin: 'anonymous', transparentCorners: false, // 选中时,角是被填充了。true 空心;false 实心 // cornerColor: "#a1de93", // 选中时,角的颜色是 青色 - },{ crossOrigin: 'Anonymous' }) + }) position.height = img.height*scaleWH+margin if(key == 'sketchboardFiles'){ position.x += img.width*scaleWH+margin @@ -227,7 +234,7 @@ export default defineComponent({ canvas.add(img); oldKey = key resolve() - }) + },{crossOrigin: 'Anonymous'}) } }); }