From 81dece8fa5b2d2cb5a1ba86cf50a76a9684c9f0c Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 28 May 2021 10:37:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=BA=E5=AF=B8=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/canvas/components/Toolbar.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/canvas/components/Toolbar.vue b/frontend/src/components/canvas/components/Toolbar.vue index fb885067bf..2c32b55ed9 100644 --- a/frontend/src/components/canvas/components/Toolbar.vue +++ b/frontend/src/components/canvas/components/Toolbar.vue @@ -175,6 +175,10 @@ export default { const fileResult = res.target.result const img = new Image() img.onload = () => { + const scaleWith = img.width / 400 + const scaleHeight = img.height / 200 + let scale = scaleWith > scaleHeight ? scaleWith : scaleHeight + scale = scale > 1 ? scale : 1 this.$store.commit('addComponent', { component: { ...commonAttr, @@ -187,8 +191,8 @@ export default { ...commonStyle, top: 0, left: 0, - width: img.width, - height: img.height + width: img.width / scale, + height: img.height / scale } } })