diff --git a/core/core-frontend/src/utils/canvasUtils.ts b/core/core-frontend/src/utils/canvasUtils.ts index d21ae7b72e..c1b41bddeb 100644 --- a/core/core-frontend/src/utils/canvasUtils.ts +++ b/core/core-frontend/src/utils/canvasUtils.ts @@ -174,6 +174,48 @@ export async function initCanvasData(dvId, busiFlag, callBack) { ) } +export async function backCanvasData(dvId, busiFlag, callBack) { + initCanvasDataPrepare(dvId, busiFlag, function ({ canvasDataResult, canvasStyleResult }) { + const componentDataCopy = canvasDataResult.filter(ele => !!ele.inMobile) + const componentDataId = componentDataCopy.map(ele => ele.id) + componentData.value.forEach(ele => { + ele.inMobile = componentDataId.includes(ele.id) + if (ele.inMobile) { + const { mx, my, mSizeX, mSizeY } = componentDataCopy.find(itx => itx.id === ele.id) + ele.mx = mx + ele.my = my + ele.mSizeX = mSizeX + ele.mSizeY = mSizeY + if (ele.component === 'DeTabs') { + ele.propValue.forEach(tabItem => { + tabItem.componentData.forEach(tabComponent => { + tabComponent.mx = tabComponent.mx + tabComponent.my = tabComponent.my + tabComponent.mSizeX = tabComponent.mSizeX + tabComponent.mSizeY = tabComponent.mSizeY + }) + }) + } + } + }) + dvMainStore.setComponentData(componentData.value) + const canvasStyleDataCopy = cloneDeep(canvasStyleData.value) + if (!canvasStyleDataCopy.mobileSetting) { + canvasStyleDataCopy.mobileSetting = { + backgroundColorSelect: false, + background: '', + color: '#ffffff', + backgroundImageEnable: false, + customSetting: false + } + } else { + canvasStyleDataCopy.mobileSetting = canvasStyleResult.mobileSetting + } + dvMainStore.setCanvasStyle(canvasStyleDataCopy) + callBack() + }) +} + export function initCanvasDataMobile(dvId, busiFlag, callBack) { initCanvasDataPrepare( dvId, diff --git a/core/core-frontend/src/views/dashboard/MobileConfigPanel.vue b/core/core-frontend/src/views/dashboard/MobileConfigPanel.vue index a34c45b8f8..b971fb7471 100644 --- a/core/core-frontend/src/views/dashboard/MobileConfigPanel.vue +++ b/core/core-frontend/src/views/dashboard/MobileConfigPanel.vue @@ -8,6 +8,7 @@ import { useEmbedded } from '@/store/modules/embedded' import { canvasSave } from '@/utils/canvasUtils' import { useEmitt } from '@/hooks/web/useEmitt' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' +import { backCanvasData } from '@/utils/canvasUtils' import { storeToRefs } from 'pinia' import { debounce } from 'lodash-es' import mobileHeader from '@/assets/img/mobile-header.png' @@ -175,6 +176,7 @@ onBeforeUnmount(() => { }) const addToMobile = com => { + if (mobileLoading.value) return com.inMobile = true changeTimes.value++ mobileStatusChange('addToMobile', JSON.parse(JSON.stringify(unref(com)))) @@ -194,7 +196,10 @@ const handleBack = () => { showClose: false }).then(() => { setTimeout(() => { - mobileStatusChange('mobilePatch', undefined) + backCanvasData(dvInfo.value.id, 'dashboard', () => { + changeTimes.value = 0 + emits('pcMode') + }) }, 100) }) } diff --git a/core/core-frontend/src/views/share/link/mobile.vue b/core/core-frontend/src/views/share/link/mobile.vue index d039fcbb3b..d30cfde54e 100644 --- a/core/core-frontend/src/views/share/link/mobile.vue +++ b/core/core-frontend/src/views/share/link/mobile.vue @@ -1,23 +1,33 @@ @@ -96,3 +119,15 @@ onMounted(async () => { position: relative; } +