From 20cd55a1be5b4fffcd10b56bbdd919afcbbd5c30 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 12 Jan 2024 09:52:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E5=8F=AF=E8=A7=86=E5=8C=96=E8=B5=84=E6=BA=90=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=8F=B0=E6=9C=89=E5=BC=82=E5=B8=B8=E9=94=99=E8=AF=AF=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/api/watermark.ts | 2 +- .../data-visualization/canvas/CanvasCore.vue | 6 +++++- .../src/store/modules/data-visualization/dvMain.ts | 4 ++-- core/core-frontend/src/views/dashboard/index.vue | 12 +++++++++++- .../src/views/data-visualization/index.vue | 13 ++++++++++++- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/core/core-frontend/src/api/watermark.ts b/core/core-frontend/src/api/watermark.ts index dacfd4c8c3..c5caf45e26 100644 --- a/core/core-frontend/src/api/watermark.ts +++ b/core/core-frontend/src/api/watermark.ts @@ -2,4 +2,4 @@ import request from '@/config/axios' export const watermarkSave = params => request.post({ url: '/watermark/save', data: params }) -export const watermarkFind = () => request.get({ url: 'watermark/find' }) +export const watermarkFind = async () => request.get({ url: 'watermark/find' }) diff --git a/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue b/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue index 951f781876..62b1cff622 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue @@ -212,7 +212,11 @@ watch( ) const initWatermark = (waterDomId = 'editor-canvas-main') => { - if (dvInfo.value.watermarkInfo && isMainCanvas(canvasId.value)) { + if ( + dvInfo.value.watermarkInfo && + dvInfo.value.watermarkInfo.settingContent && + isMainCanvas(canvasId.value) + ) { const scale = dashboardActive.value ? 1 : curScale.value if (userInfo.value) { activeWatermark( diff --git a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts index 0ed6f0c9ea..4c3f21cba4 100644 --- a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts +++ b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts @@ -890,7 +890,7 @@ export const dvMainStore = defineStore('dataVisualization', { } } }, - createInit(dvType, resourceId?, pid?) { + createInit(dvType, resourceId?, pid?, watermarkInfo?) { const optName = dvType === 'dashboard' ? '新建仪表板' : '新建数据大屏' this.dvInfo = { dataState: 'prepare', @@ -901,7 +901,7 @@ export const dvMainStore = defineStore('dataVisualization', { type: dvType, status: 1, selfWatermarkStatus: true, - watermarkInfo: {} + watermarkInfo: watermarkInfo } const canvasStyleDataNew = dvType === 'dashboard' diff --git a/core/core-frontend/src/views/dashboard/index.vue b/core/core-frontend/src/views/dashboard/index.vue index 5006c219e1..c15bd9f280 100644 --- a/core/core-frontend/src/views/dashboard/index.vue +++ b/core/core-frontend/src/views/dashboard/index.vue @@ -17,6 +17,7 @@ import { check, compareStorage } from '@/utils/CrossPermission' import { useCache } from '@/hooks/web/useCache' import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot' import { interactiveStoreWithOut } from '@/store/modules/interactive' +import { watermarkFind } from '@/api/watermark' const interactiveStore = interactiveStoreWithOut() const { wsCache } = useCache() const eventCheck = e => { @@ -93,8 +94,17 @@ onMounted(async () => { }) } else if (opt && opt === 'create') { dataInitState.value = false + let watermarkBaseInfo + try { + await watermarkFind().then(rsp => { + watermarkBaseInfo = rsp.data + watermarkBaseInfo.settingContent = JSON.parse(watermarkBaseInfo.settingContent) + }) + } catch (e) { + console.error('can not find watermark info') + } nextTick(() => { - dvMainStore.createInit('dashboard', null, pid) + dvMainStore.createInit('dashboard', null, pid, watermarkBaseInfo) // 从模板新建 if (createType === 'template') { const deTemplateDataStr = wsCache.get(`de-template-data`) diff --git a/core/core-frontend/src/views/data-visualization/index.vue b/core/core-frontend/src/views/data-visualization/index.vue index 8a37ac5bcd..3fb908cad7 100644 --- a/core/core-frontend/src/views/data-visualization/index.vue +++ b/core/core-frontend/src/views/data-visualization/index.vue @@ -26,6 +26,7 @@ import { check, compareStorage } from '@/utils/CrossPermission' import { useCache } from '@/hooks/web/useCache' import RealTimeListTree from '@/components/data-visualization/RealTimeListTree.vue' import { interactiveStoreWithOut } from '@/store/modules/interactive' +import { watermarkFind } from '@/api/watermark' const interactiveStore = interactiveStoreWithOut() const { wsCache } = useCache() const eventCheck = e => { @@ -221,7 +222,17 @@ onMounted(async () => { }) } else if (opt && opt === 'create') { state.canvasInitStatus = false - dvMainStore.createInit('dataV', null, pid) + let watermarkBaseInfo + try { + await watermarkFind().then(rsp => { + watermarkBaseInfo = rsp.data + watermarkBaseInfo.settingContent = JSON.parse(watermarkBaseInfo.settingContent) + }) + } catch (e) { + console.error('can not find watermark info') + } + + dvMainStore.createInit('dataV', null, pid, watermarkBaseInfo) nextTick(() => { state.canvasInitStatus = true dvMainStore.setDataPrepareState(true)