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 f26f41c570..0d0fc03de4 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/DePreview.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/DePreview.vue @@ -100,6 +100,11 @@ const props = defineProps({ showLinkageButton: { type: Boolean, default: true + }, + outerScreenAdaptor: { + type: String, + required: false, + default: null } }) @@ -115,7 +120,8 @@ const { outerScale, outerSearchCount, showPopBar, - fontFamily + fontFamily, + outerScreenAdaptor } = toRefs(props) const domId = 'preview-' + canvasId.value const scaleWidthPoint = ref(100) @@ -136,17 +142,21 @@ const state = reactive({ scrollMain: 0 }) +const screenAdaptor = computed(() => { + return outerScreenAdaptor.value || canvasStyleData.value?.screenAdaptor +}) + const curSearchCount = computed(() => { return outerSearchCount.value + searchCount.value }) // 大屏是否保持宽高比例 非全屏 full 都需要保持宽高比例 const dataVKeepRadio = computed(() => { - return canvasStyleData.value?.screenAdaptor !== 'full' + return screenAdaptor.value !== 'full' }) // 仪表板是否跟随宽度缩放 非全屏 full 都需要保持宽高比例 const dashboardScaleWithWidth = computed(() => { - return isDashboard() && canvasStyleData.value?.dashboardAdaptor === 'withWidth' + return isDashboard() && screenAdaptor.value === 'withWidth' }) const isReport = computed(() => { return !!router.currentRoute.value.query?.report @@ -176,11 +186,11 @@ const canvasStyle = computed(() => { } if (canvasStyleData.value && canvasStyleData.value.width && isMainCanvas(canvasId.value)) { style = getCanvasStyle(canvasStyleData.value) - if (canvasStyleData.value?.screenAdaptor === 'keep') { + if (screenAdaptor.value === 'keep') { style['height'] = canvasStyleData.value?.height + 'px' style['width'] = canvasStyleData.value?.width + 'px' style['margin'] = 'auto' - } else if (canvasStyleData.value?.screenAdaptor === 'keepProportion') { + } else if (screenAdaptor.value === 'keepProportion') { style['aspect-ratio'] = canvasStyleData.value?.width / canvasStyleData.value?.height style['height'] = 'auto' style['width'] = 'auto' @@ -189,12 +199,11 @@ const canvasStyle = computed(() => { ? downloadStatus.value ? getDownloadStatusMainHeight() : '100%' - : !canvasStyleData.value?.screenAdaptor || - canvasStyleData.value?.screenAdaptor === 'widthFirst' + : !screenAdaptor.value || screenAdaptor.value === 'widthFirst' ? changeStyleWithScale(canvasStyleData.value?.height, scaleMin.value) + 'px' : '100%' style['width'] = - !dashboardActive.value && canvasStyleData.value?.screenAdaptor === 'heightFirst' + !dashboardActive.value && screenAdaptor.value === 'heightFirst' ? changeStyleWithScale(canvasStyleData.value?.width, scaleHeightPoint.value) + 'px' : '100%' } @@ -518,9 +527,15 @@ const scrollPreview = () => { } const showUnpublishFlag = computed(() => dvInfo.value?.status === 0 && isMainCanvas(canvasId.value)) - +const getPreviewCanvasSize = () => { + return { + innerWidth: previewCanvas.value.clientWidth, + innerHeight: previewCanvas.value.clientHeight + } +} defineExpose({ restore, + getPreviewCanvasSize, getDownloadStatusMainHeightV2 }) diff --git a/core/core-frontend/src/style/index.less b/core/core-frontend/src/style/index.less index 816a0f8e87..f47588e487 100644 --- a/core/core-frontend/src/style/index.less +++ b/core/core-frontend/src/style/index.less @@ -604,6 +604,7 @@ strong { width: 100%; height: 100%; display: inherit; + justify-content: center; } .preview-content-inner-height-first { diff --git a/core/core-frontend/src/views/data-visualization/DvPreview.vue b/core/core-frontend/src/views/data-visualization/DvPreview.vue index e6066e4852..ed1927466e 100644 --- a/core/core-frontend/src/views/data-visualization/DvPreview.vue +++ b/core/core-frontend/src/views/data-visualization/DvPreview.vue @@ -1,13 +1,15 @@