From abe253124545ee2a96ebb7de350d52eac6d01dd1 Mon Sep 17 00:00:00 2001 From: "wu.jian2" Date: Fri, 22 Dec 2023 11:34:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E5=A4=A7=E5=B1=8F=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=95=B0=E6=8D=AE=E6=97=B6=E5=92=8C=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E7=BB=84=E4=BB=B6=E6=97=B6=EF=BC=8C=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E4=BF=9D=E5=AD=98=E5=B0=81=E9=9D=A2=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=8F=90=E7=A4=BA=E8=AF=AD?= =?UTF-8?q?=EF=BC=8C=E5=91=8A=E8=AF=89=E4=BD=BF=E7=94=A8=E8=80=85=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E8=B5=84=E6=BA=90=E8=B7=A8=E5=9F=9F=EF=BC=8C=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E5=85=88=E5=B0=86=E8=B5=84=E6=BA=90=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=88=B0=E8=B5=84=E6=BA=90=E5=BA=93=E5=86=8D=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BigScreenDesign/PageDesignTop.vue | 47 +++++++++++++++---- data-room-ui/packages/BizComponent/index.vue | 16 ++++++- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/data-room-ui/packages/BigScreenDesign/PageDesignTop.vue b/data-room-ui/packages/BigScreenDesign/PageDesignTop.vue index a5b5cfcb..ee746e4d 100644 --- a/data-room-ui/packages/BigScreenDesign/PageDesignTop.vue +++ b/data-room-ui/packages/BigScreenDesign/PageDesignTop.vue @@ -439,12 +439,32 @@ export default { } else { pageInfo.isPreview = false this.saveLoading = true + pageInfo.coverPicture = this.initialCoverPicture const node = document.querySelector('.render-theme-wrap') let dataUrl = '' + let res = null try { dataUrl = await toJpeg(node, { quality: 0.2 }) } catch (error) { - console.info(error) + if (error.type === 'error') { + // 判断的error.currentTarget是img标签,如果是的,就弹出消息说是图片跨域 + if (error.currentTarget.tagName.toLowerCase() === 'img') { + // 确认框 + this.$confirm('保存封面失败,我们将使用上次保存的封面,它不会影响其他数据的保存。由于图片资源跨域问题导致使用toDataURL API生成图片失败,我们需要将图片上传到资源库。然后在组件中使用资源库中的图片资源,以确保没有跨域问题。', '提示', { + confirmButtonText: '确定', + type: 'warning', + customClass: 'bs-el-message-box' + }).then(async () => { + res = await saveScreen(pageInfo) + this.$message.success('数据保存成功') + }).catch(async () => { + res = await saveScreen(pageInfo) + this.$message.success('数据保存成功') + }) + } + } else { + this.$message.warning('出现未知错误,请重试') + } } if (dataUrl) { if (showSize(dataUrl) > 200) { @@ -464,12 +484,9 @@ export default { } else { pageInfo.coverPicture = dataUrl } - } else { - this.$message.warning('保存封面失败,将使用上次保存的封面') - pageInfo.coverPicture = this.initialCoverPicture + res = await saveScreen(pageInfo) + this.$message.success('数据保存成功') } - const res = await saveScreen(pageInfo) - this.$message.success('保存成功') return res } } catch (error) { @@ -554,10 +571,22 @@ export default { this.saveAndPreviewLoading = false // 恢复跑马灯动画 EventBus.$emit('startMarquee') - }) - .catch(() => { - this.$message.warning('出现未知错误,请重试') + }).catch((error) => { this.saveAndPreviewLoading = false + if (error.type === 'error') { + // 判断的error.currentTarget是img标签,如果是的,就弹出消息说是图片跨域 + if (error.currentTarget.tagName.toLowerCase() === 'img') { + // 确认框 + this.$confirm('图片资源跨域导致使用toDataURL API生成图片失败,请将图片上传到资源库,然后在组件中使用资源库中的图片资源,确保没有跨域问题。', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + customClass: 'bs-el-message-box' + }).then(() => { }).catch(() => { }) + } + } else { + this.$message.warning('出现未知错误,请重试') + } }) } } diff --git a/data-room-ui/packages/BizComponent/index.vue b/data-room-ui/packages/BizComponent/index.vue index dc1c9471..e3d53332 100644 --- a/data-room-ui/packages/BizComponent/index.vue +++ b/data-room-ui/packages/BizComponent/index.vue @@ -415,9 +415,21 @@ export default { this.loading = false }) .catch((error) => { - console.info(error) - this.$message.warning('出现未知错误,请重试') this.loading = false + if (error.type === 'error') { + // 判断的error.currentTarget是img标签,如果是的,就弹出消息说是图片跨域 + if (error.currentTarget.tagName.toLowerCase() === 'img') { + // 确认框 + this.$confirm('图片资源跨域导致使用toDataURL API生成图片失败,请将图片上传到资源库,然后在组件中使用资源库中的图片资源,确保没有跨域问题。', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + customClass: 'bs-el-message-box' + }).then(() => { }).catch(() => { }) + } + } else { + this.$message.warning('出现未知错误,请重试') + } }) }, pageJump () {