From a66cced73c2f91c2d3507526456c84ffb5f02270 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Mon, 25 Dec 2023 20:50:50 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=E5=8E=BB=E9=99=A4=E5=AF=BC=E5=87=BApdf?= =?UTF-8?q?=E7=9A=84=E7=89=B9=E5=88=AB=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/Export.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/simple-mind-map/src/plugins/Export.js b/simple-mind-map/src/plugins/Export.js index b49e46f5..9d6c5d40 100644 --- a/simple-mind-map/src/plugins/Export.js +++ b/simple-mind-map/src/plugins/Export.js @@ -92,7 +92,7 @@ class Export { } // svg转png - svgToPng(svgSrc, transparent, ignoreDpr = false) { + svgToPng(svgSrc, transparent) { return new Promise((resolve, reject) => { const img = new Image() // 跨域图片需要添加这个属性,否则画布被污染了无法导出图片 @@ -100,12 +100,10 @@ class Export { img.onload = async () => { try { const canvas = document.createElement('canvas') - const dpr = ignoreDpr - ? 1 - : Math.max( - window.devicePixelRatio, - this.mindMap.opt.minExportImgCanvasScale - ) + const dpr = Math.max( + window.devicePixelRatio, + this.mindMap.opt.minExportImgCanvasScale + ) let imgWidth = img.width let imgHeight = img.height canvas.width = imgWidth * dpr @@ -215,9 +213,7 @@ class Export { if (!this.mindMap.doExportPDF) { throw new Error('请注册ExportPDF插件') } - const { str } = await this.getSvgData() - const svgUrl = await this.fixSvgStrAndToBlob(str) - const img = await this.svgToPng(svgUrl, transparent, true) + const img = await this.png(name, transparent) await this.mindMap.doExportPDF.pdf(name, img) }