From 05f07555327a8ba99b06edd2af8af3ea069691b4 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 10 Apr 2025 17:49:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=9B=BE=E8=A1=A8):=20=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=9B=BE=E8=A1=A8=E5=8F=AF=E8=83=BD=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-visualization/canvas/ComponentWrapper.vue | 7 +------ .../src/components/data-visualization/canvas/Shape.vue | 4 +++- .../src/components/visualization/ComponentEditBar.vue | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/core/core-frontend/src/components/data-visualization/canvas/ComponentWrapper.vue b/core/core-frontend/src/components/data-visualization/canvas/ComponentWrapper.vue index 87e356f11c..b714f5c37e 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/ComponentWrapper.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/ComponentWrapper.vue @@ -181,12 +181,6 @@ const handleInnerMouseDown = e => { onMounted(() => { currentInstance = getCurrentInstance() - const methodName = 'componentImageDownload-' + config.value.id - if (!useEmitt().emitter.all.get(methodName)?.length) { - useEmitt().emitter.on(methodName, () => { - htmlToImage() - }) - } }) const onClick = e => { @@ -417,6 +411,7 @@ const commonParams = computed(() => { :element="config" :show-position="showPosition" :class="{ 'wrapper-edit-bar-active': active }" + @componentImageDownload="htmlToImage" @userViewEnlargeOpen="opt => emits('userViewEnlargeOpen', opt)" @datasetParamsInit="() => emits('datasetParamsInit')" > diff --git a/core/core-frontend/src/components/data-visualization/canvas/Shape.vue b/core/core-frontend/src/components/data-visualization/canvas/Shape.vue index c374e7099d..c2c4eb1302 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/Shape.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/Shape.vue @@ -59,6 +59,7 @@ :element="element" :show-position="showPosition" :canvas-id="canvasId" + @componentImageDownload="htmlToImage" @userViewEnlargeOpen="userViewEnlargeOpen" @datasetParamsInit="datasetParamsInit" @linkJumpSetOpen="linkJumpSetOpen" @@ -1124,7 +1125,8 @@ const htmlToImage = () => { useEmitt().emitter.emit('l7-prepare-picture', element.value.id) setTimeout(() => { activeWatermarkCheckUser(viewDemoInnerId.value, 'canvas-main', scale.value) - downloadCanvas2('img', componentInnerRef.value, '图表', () => { + const dom = document.getElementById(viewDemoInnerId.value) + downloadCanvas2('img', dom, '图表', () => { // do callback removeActiveWatermark(viewDemoInnerId.value) downLoading.value = false diff --git a/core/core-frontend/src/components/visualization/ComponentEditBar.vue b/core/core-frontend/src/components/visualization/ComponentEditBar.vue index 08fe631445..c275e3785c 100644 --- a/core/core-frontend/src/components/visualization/ComponentEditBar.vue +++ b/core/core-frontend/src/components/visualization/ComponentEditBar.vue @@ -268,7 +268,8 @@ const emits = defineEmits([ 'showViewDetails', 'amRemoveItem', 'linkJumpSetOpen', - 'linkageSetOpen' + 'linkageSetOpen', + 'componentImageDownload' ]) const { t } = useI18n() const { emitter } = useEmitt() @@ -485,8 +486,7 @@ const exportAsExcel = () => { }) } const exportAsImage = () => { - // do export - useEmitt().emitter.emit('componentImageDownload-' + element.value.id) + emits('componentImageDownload') } const deleteComponent = () => { eventBus.emit('removeMatrixItem-' + canvasId.value, index.value)