From f6526d8d863a657426ae426910580c1cbc8228ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=98=89=E8=B1=AA?= <42510293+ziyujiahao@users.noreply.github.com> Date: Tue, 22 Jul 2025 17:32:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF=E3=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=A7=E5=B1=8F):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=B5=8F=E8=A7=88=E5=99=A8=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=87=BA=E7=8E=B0=E9=83=A8=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E7=A0=81=E7=A9=BA=E7=99=BD=E9=97=AE=E9=A2=98=20(#16546)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/index.html | 9 +-- .../data-visualization/canvas/DePreview.vue | 3 +- .../data-visualization/PreviewCanvas.vue | 59 +++++++++++++++++-- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/core/core-frontend/index.html b/core/core-frontend/index.html index 82a8495798..5082b452a5 100644 --- a/core/core-frontend/index.html +++ b/core/core-frontend/index.html @@ -1,16 +1,17 @@ - + + - -
+ +
- \ No newline at end of file + diff --git a/core/core-frontend/src/components/data-visualization/canvas/DePreview.vue b/core/core-frontend/src/components/data-visualization/canvas/DePreview.vue index bafbc843c1..7b7a3f90b7 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/DePreview.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/DePreview.vue @@ -486,7 +486,8 @@ const scrollPreview = () => { const showUnpublishFlag = computed(() => dvInfo.value?.status === 0 && isMainCanvas(canvasId.value)) defineExpose({ - restore + restore, + getDownloadStatusMainHeight }) diff --git a/core/core-frontend/src/views/data-visualization/PreviewCanvas.vue b/core/core-frontend/src/views/data-visualization/PreviewCanvas.vue index dd600d7cf1..acb053caab 100644 --- a/core/core-frontend/src/views/data-visualization/PreviewCanvas.vue +++ b/core/core-frontend/src/views/data-visualization/PreviewCanvas.vue @@ -38,7 +38,8 @@ const state = reactive({ showOffset: { top: 3, left: 3 - } + }, + containerMainHeight: '3000px' }) const props = defineProps({ @@ -216,17 +217,52 @@ onMounted(async () => { return } dvMainStore.setEmbeddedCallBack(callBackFlag || 'no') + + window.matchMedia('print').addListener(async mql => { + if (mql.matches) { + await prepareForPrint() + } + }) }) const dataVKeepSize = computed(() => { return state.canvasStylePreview?.screenAdaptor === 'keep' }) -const freezeStyle = computed(() => [ - { '--top-show-offset': state.showOffset.top }, - { '--left-show-offset': state.showOffset.left } -]) +watch( + () => state.containerMainHeight, + newVal => { + if (previewCanvasContainer.value) { + previewCanvasContainer.value.style.setProperty('--print-height', newVal) + } + } +) +const freezeStyle = computed(() => { + return [ + { '--top-show-offset': state.showOffset.top }, + { '--left-show-offset': state.showOffset.left }, + { '--print-height': state.containerMainHeight } + ] +}) + +const dvPreview = ref(null) +const getPrintHeight = async () => { + if (dvPreview.value && dvPreview.value.getDownloadStatusMainHeight) { + state.containerMainHeight = await dvPreview.value.getDownloadStatusMainHeight() + } +} + +// 打印前准备 +const prepareForPrint = async () => { + await getPrintHeight() +} + +// 暴露方法给外部调用打印 +const handlePrint = async () => { + await prepareForPrint() + window.print() +} defineExpose({ loadCanvasDataAsync }) @@ -279,6 +315,19 @@ defineExpose({ /> + +