From 568a989e9b69cafba5672ac4c6ae08d574837a02 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 25 Nov 2022 16:36:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BB=AA=E8=A1=A8=E6=9D=BF=E5=AF=BC=E5=87=BAPDF?= =?UTF-8?q?=E6=B0=B4=E5=8D=B0=E4=B8=8D=E5=85=A8=E6=88=96=E8=80=85=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=B0=B4=E5=8D=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/components/editor/Preview.vue | 64 +++++++++++-------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/frontend/src/components/canvas/components/editor/Preview.vue b/frontend/src/components/canvas/components/editor/Preview.vue index 9e41f1a0b0..9c27ac73e7 100644 --- a/frontend/src/components/canvas/components/editor/Preview.vue +++ b/frontend/src/components/canvas/components/editor/Preview.vue @@ -189,7 +189,8 @@ export default { }, data() { return { - canvasInfoTemp: 'preview-temp-canvas-main', + mainHeightCount: null, + userInfo: null, previewMainDomId: 'preview-main-' + this.canvasId, previewDomId: 'preview-' + this.canvasId, previewRefId: 'preview-ref-' + this.canvasId, @@ -230,6 +231,9 @@ export default { } }, computed: { + screenShotStatues() { + return this.exporting || this.screenShot || this.backScreenShot + }, mainActiveName() { return this.$store.state.panel.mainActiveName }, @@ -345,6 +349,18 @@ export default { this.canvasStyleDataInit() }, deep: true + }, + mainHeight: { + handler(newVal, oldVla) { + const _this = this + _this.$nextTick(() => { + if (_this.screenShotStatues) { + _this.initWatermark('preview-temp-canvas-main') + } else { + _this.initWatermark() + } + }) + } } }, created() { @@ -377,12 +393,16 @@ export default { bus.$off('trigger-reset-button', this.triggerResetButton) }, methods: { - initWatermark() { + initWatermark(waterDomId = 'preview-main-canvas-main') { if (this.panelInfo.watermarkInfo && this.canvasId === 'canvas-main') { - userLoginInfo().then(res => { - const userInfo = res.data - activeWatermark(this.panelInfo.watermarkInfo.settingContent, userInfo, 'preview-main-canvas-main', this.canvasId, this.panelInfo.watermarkOpen) - }) + if (this.userInfo) { + activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, this.canvasId, this.panelInfo.watermarkOpen) + } else { + userLoginInfo().then(res => { + this.userInfo = res.data + activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, this.canvasId, this.panelInfo.watermarkOpen) + }) + } } }, isMainCanvas() { @@ -606,6 +626,7 @@ export default { _this.$nextTick(() => { // 将mainHeight 修改为px 临时解决html2canvas 截图不全的问题 _this.mainHeight = tempCanvas.scrollHeight + 'px!important' + _this.mainHeightCount = tempCanvas.scrollHeight this.$emit('mainHeightChange', _this.mainHeight) }) }) @@ -623,28 +644,17 @@ export default { document.getElementById('preview-canvas-main').style.height = (scrollHeight + 'px') setTimeout(() => { - const timer = setInterval(() => { - const containerDom = document.getElementById(domId) - const masks = containerDom.getElementsByClassName('el-loading-mask') - const mapLoadingArr = containerDom.getElementsByClassName('.symbol-map-loading') - if (masks?.length) { - const hideMasks = [...masks].filter(item => item.style?.display === 'none') - if (masks.length === hideMasks.length && !mapLoadingArr?.length) { - html2canvas(containerDom).then(canvas => { - const snapshot = canvas.toDataURL('image/jpeg', 1) // 是图片质量 - this.dataLoading = false - this.$emit('change-load-status', false) - this.exporting = false - this.backScreenShot = false - if (snapshot !== '') { - this.snapshotInfo = snapshot - this.pdfExportShow = true - } - }) - clearInterval(timer) - } + html2canvas(document.getElementById(domId)).then(canvas => { + const snapshot = canvas.toDataURL('image/jpeg', 1) // 是图片质量 + this.dataLoading = false + this.$emit('change-load-status', false) + this.exporting = false + this.backScreenShot = false + if (snapshot !== '') { + this.snapshotInfo = snapshot + this.pdfExportShow = true } - }, 1000) + }) }, 2500) }, 500) },