From 3f659af1e1747fc2bcb17abb79a08e33adbf9553 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Wed, 16 Aug 2023 17:20:05 +0800 Subject: [PATCH] =?UTF-8?q?Featc=EF=BC=9A=E5=88=A0=E9=99=A4=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=9A=84exportPadding=E9=85=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E4=BD=BF=E7=94=A8exportPaddingX=E5=92=8Cexpo?= =?UTF-8?q?rtPaddingY=E9=85=8D=E7=BD=AE=EF=BC=9B=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=9B=BE=E7=89=87=E6=97=B6=E7=9A=84=E5=8F=8C?= =?UTF-8?q?=E9=87=8Dpadding=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/Export.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/simple-mind-map/src/plugins/Export.js b/simple-mind-map/src/plugins/Export.js index a5747595..7820ac72 100644 --- a/simple-mind-map/src/plugins/Export.js +++ b/simple-mind-map/src/plugins/Export.js @@ -8,7 +8,6 @@ class Export { // 构造函数 constructor(opt) { this.mindMap = opt.mindMap - this.exportPadding = this.mindMap.opt.exportPadding } // 导出 @@ -51,14 +50,17 @@ class Export { // svg转png svgToPng(svgSrc, transparent) { return new Promise((resolve, reject) => { + // const { exportPaddingX, exportPaddingY } = this.mindMap.opt + let exportPaddingX = 0 + let exportPaddingY = 0 const img = new Image() // 跨域图片需要添加这个属性,否则画布被污染了无法导出图片 img.setAttribute('crossOrigin', 'anonymous') img.onload = async () => { try { let canvas = document.createElement('canvas') - canvas.width = img.width + this.exportPadding * 2 - canvas.height = img.height + this.exportPadding * 2 + canvas.width = img.width + exportPaddingX * 2 + canvas.height = img.height + exportPaddingY * 2 let ctx = canvas.getContext('2d') // 绘制背景 if (!transparent) { @@ -71,8 +73,8 @@ class Export { 0, img.width, img.height, - this.exportPadding, - this.exportPadding, + exportPaddingX, + exportPaddingY, img.width, img.height )