From c9f551dee7858f73ea389344d95a91cc7af1b264 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 8 Oct 2024 18:05:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=8D=E7=94=A8=E4=BB=AA=E8=A1=A8=E6=9D=BF?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=9C=80=E7=BB=88=E6=94=BE=E7=BD=AE=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=A4=8D=E7=94=A8=E4=BB=AA?= =?UTF-8?q?=E8=A1=A8=E6=9D=BF=E8=BE=83=E9=95=BF=E6=97=B6=EF=BC=8C=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E8=A7=86=E5=9B=BE=E5=9C=A8=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E6=9D=BF=E4=B8=AD=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/store/modules/data-visualization/copy.ts | 3 ++- core/core-frontend/src/utils/canvasUtils.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/core-frontend/src/store/modules/data-visualization/copy.ts b/core/core-frontend/src/store/modules/data-visualization/copy.ts index 18e5224515..071335bde0 100644 --- a/core/core-frontend/src/store/modules/data-visualization/copy.ts +++ b/core/core-frontend/src/store/modules/data-visualization/copy.ts @@ -8,6 +8,7 @@ import eventBus from '@/utils/eventBus' import { adaptCurThemeCommonStyle } from '@/utils/canvasStyle' import { composeStoreWithOut } from '@/store/modules/data-visualization/compose' import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot' +import { maxYComponentCount } from '@/utils/canvasUtils' const dvMainStore = dvMainStoreWithOut() const composeStore = composeStoreWithOut() @@ -62,7 +63,7 @@ export const copyStore = defineStore('copy', { } // dataV 数据大屏 newComponent.x = newComponent.sizeX * xPositionOffset + 1 - newComponent.y = 200 + newComponent.y = maxYComponentCount() + 10 // dataV 数据大屏 newComponent.style.left = 0 newComponent.style.top = 0 diff --git a/core/core-frontend/src/utils/canvasUtils.ts b/core/core-frontend/src/utils/canvasUtils.ts index 3049a5017e..bdc0352fcb 100644 --- a/core/core-frontend/src/utils/canvasUtils.ts +++ b/core/core-frontend/src/utils/canvasUtils.ts @@ -731,3 +731,14 @@ export function componentPreSort(componentData) { }) } } + +export function maxYComponentCount() { + if (componentData.value.length === 0) { + return 1 + } else { + return componentData.value + .filter(item => item.y) + .map(item => item.y + item.sizeY) // 计算每个元素的 y + sizeY + .reduce((max, current) => Math.max(max, current), 0) + } +}