Merge pull request #13003 from dataease/pr@dev-v2@fix_mobile-style

fix(仪表板): 修复移动端PC端反复切换,样式状态未同步问题
This commit is contained in:
王嘉豪 2024-10-30 14:21:33 +08:00 committed by GitHub
commit bd56596d88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 8 deletions

View File

@ -33,6 +33,9 @@ const getComponentStyleDefault = () => {
} }
} }
const mobileStatusChange = (type, value) => { const mobileStatusChange = (type, value) => {
if (type === 'componentStyleChange') {
changeTimes.value++
}
const iframe = document.querySelector('iframe') const iframe = document.querySelector('iframe')
if (iframe) { if (iframe) {
iframe.contentWindow.postMessage( iframe.contentWindow.postMessage(
@ -52,7 +55,18 @@ const iframeSrc = computed(() => {
: './mobile.html#/panel' : './mobile.html#/panel'
}) })
const handleLoad = () => { const handleLoad = () => {
canvasViewInfoMobile.value = JSON.parse(JSON.stringify(unref(canvasViewInfo))) const mobileViewInfo = JSON.parse(JSON.stringify(unref(canvasViewInfo)))
//
if (!!mobileViewInfo) {
Object.keys(mobileViewInfo).forEach(key => {
const { customAttrMobile, customStyleMobile } = canvasViewInfo.value[key]
mobileViewInfo[key]['customAttr'] =
customAttrMobile || canvasViewInfo.value[key]['customAttrMobile']
mobileViewInfo[key]['customStyle'] =
customStyleMobile || canvasViewInfo.value[key]['customStyleMobile']
})
}
canvasViewInfoMobile.value = mobileViewInfo
mobileStatusChange( mobileStatusChange(
'panelInit', 'panelInit',
JSON.parse( JSON.parse(
@ -61,7 +75,7 @@ const handleLoad = () => {
JSON.stringify(unref(componentData.value.filter(ele => !!ele.inMobile))) JSON.stringify(unref(componentData.value.filter(ele => !!ele.inMobile)))
), ),
canvasStyleData: JSON.parse(JSON.stringify(unref(canvasStyleData))), canvasStyleData: JSON.parse(JSON.stringify(unref(canvasStyleData))),
canvasViewInfo: JSON.parse(JSON.stringify(unref(canvasViewInfo))), canvasViewInfo: mobileViewInfo,
dvInfo: JSON.parse(JSON.stringify(unref(dvInfo))), dvInfo: JSON.parse(JSON.stringify(unref(dvInfo))),
isEmbedded: !!embeddedStore.baseUrl isEmbedded: !!embeddedStore.baseUrl
}) })

View File

@ -21,12 +21,6 @@ const checkItemPosition = component => {
const hanedleMessage = event => { const hanedleMessage = event => {
if (event.data.type === 'panelInit') { if (event.data.type === 'panelInit') {
const { componentData, canvasStyleData, dvInfo, canvasViewInfo, isEmbedded } = event.data.value const { componentData, canvasStyleData, dvInfo, canvasViewInfo, isEmbedded } = event.data.value
Object.keys(canvasViewInfo).forEach(viewId => {
const viewInfo = canvasViewInfo[viewId]
const { customAttrMobile, customStyleMobile } = viewInfo
viewInfo.customAttr = customAttrMobile || viewInfo.customAttr
viewInfo.customStyle = customStyleMobile || viewInfo.customStyle
})
componentData.forEach(ele => { componentData.forEach(ele => {
const { mx, my, mSizeX, mSizeY, mStyle, mCommonBackground } = ele const { mx, my, mSizeX, mSizeY, mStyle, mCommonBackground } = ele
ele.x = mx ele.x = mx