Merge branch 'feature' of https://github.com/wanglin2/mind-map into feature
This commit is contained in:
commit
d4fc37fc98
@ -92,7 +92,7 @@ class Export {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// svg转png
|
// svg转png
|
||||||
svgToPng(svgSrc, transparent, ignoreDpr = false) {
|
svgToPng(svgSrc, transparent) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const img = new Image()
|
const img = new Image()
|
||||||
// 跨域图片需要添加这个属性,否则画布被污染了无法导出图片
|
// 跨域图片需要添加这个属性,否则画布被污染了无法导出图片
|
||||||
@ -100,12 +100,10 @@ class Export {
|
|||||||
img.onload = async () => {
|
img.onload = async () => {
|
||||||
try {
|
try {
|
||||||
const canvas = document.createElement('canvas')
|
const canvas = document.createElement('canvas')
|
||||||
const dpr = ignoreDpr
|
const dpr = Math.max(
|
||||||
? 1
|
window.devicePixelRatio,
|
||||||
: Math.max(
|
this.mindMap.opt.minExportImgCanvasScale
|
||||||
window.devicePixelRatio,
|
)
|
||||||
this.mindMap.opt.minExportImgCanvasScale
|
|
||||||
)
|
|
||||||
let imgWidth = img.width
|
let imgWidth = img.width
|
||||||
let imgHeight = img.height
|
let imgHeight = img.height
|
||||||
canvas.width = imgWidth * dpr
|
canvas.width = imgWidth * dpr
|
||||||
@ -215,9 +213,7 @@ class Export {
|
|||||||
if (!this.mindMap.doExportPDF) {
|
if (!this.mindMap.doExportPDF) {
|
||||||
throw new Error('请注册ExportPDF插件')
|
throw new Error('请注册ExportPDF插件')
|
||||||
}
|
}
|
||||||
const { str } = await this.getSvgData()
|
const img = await this.png(name, transparent)
|
||||||
const svgUrl = await this.fixSvgStrAndToBlob(str)
|
|
||||||
const img = await this.svgToPng(svgUrl, transparent, true)
|
|
||||||
await this.mindMap.doExportPDF.pdf(name, img)
|
await this.mindMap.doExportPDF.pdf(name, img)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user