Merge pull request #7940 from dataease/pr@dev@refacto_img-download

refactor(仪表板): 固定导出仪表板图片的默认像素比,优化不同设备的导出图片的清晰度差异
This commit is contained in:
王嘉豪 2024-01-31 15:28:18 +08:00 committed by GitHub
commit 9467f3f80a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View File

@ -130,6 +130,10 @@ export default {
save() {
const _this = this
_this.exportLoading = true
//
const originalDPR = window.devicePixelRatio
// 1
window.devicePixelRatio = 2
setTimeout(() => {
_this.toExport = true
setTimeout(() => {
@ -143,6 +147,7 @@ export default {
PDF.addImage(pageData, 'JPEG', 0, 0, contentWidth, contentHeight)
PDF.save(_this.panelName + '.pdf')
_this.$emit('closePreExport')
window.devicePixelRatio = originalDPR
})
}, 1500)
}, 500)

View File

@ -462,8 +462,8 @@ export default {
imageWrapperStyle() {
if (this.exporting) {
return {
width: '1280px',
height: '720px'
width: '2560px',
height: '1440px'
}
} else {
return {
@ -720,6 +720,10 @@ export default {
downloadAsImage() {
this.dataLoading = true
//
const originalDPR = window.devicePixelRatio
// 1
window.devicePixelRatio = 2
setTimeout(() => {
this.exporting = this.changeExportingState()
setTimeout(() => {
@ -738,6 +742,7 @@ export default {
a.click()
URL.revokeObjectURL(blob)
document.body.removeChild(a)
window.devicePixelRatio = originalDPR
setTimeout(() => {
this.dataLoading = false
}, 300)
@ -750,7 +755,10 @@ export default {
// this.pdfExportShow = true
//
this.dataLoading = true
//
const originalDPR = window.devicePixelRatio
// 1
window.devicePixelRatio = 2
setTimeout(() => {
this.exporting = this.changeExportingState()
setTimeout(() => {
@ -764,6 +772,7 @@ export default {
}
})
}, 1500)
window.devicePixelRatio = originalDPR
}, 500)
},
refreshTemplateInfo() {