forked from github/dataease
Merge pull request #9538 from dataease/pr@dev-v2_bug_fix
fix(嵌入式): 嵌入式场景下仪表板切换到移动端无法正常显示
This commit is contained in:
commit
4be7208261
@ -17,7 +17,7 @@ const { start, done } = useNProgress()
|
|||||||
const interactiveStore = interactiveStoreWithOut()
|
const interactiveStore = interactiveStoreWithOut()
|
||||||
|
|
||||||
const { loadStart, loadDone } = usePageLoading()
|
const { loadStart, loadDone } = usePageLoading()
|
||||||
const whiteList = ['/login'] // 不重定向白名单
|
const whiteList = ['/login', '/panel'] // 不重定向白名单
|
||||||
|
|
||||||
router.beforeEach(async (to, _, next) => {
|
router.beforeEach(async (to, _, next) => {
|
||||||
start()
|
start()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, onMounted, unref, onBeforeUnmount, computed } from 'vue'
|
import { ref, onMounted, unref, onBeforeUnmount, computed } from 'vue'
|
||||||
import { XpackComponent } from '@/components/plugin'
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus-secondary'
|
import { ElMessage, ElMessageBox } from 'element-plus-secondary'
|
||||||
import MobileBackgroundSelector from './MobileBackgroundSelector.vue'
|
import MobileBackgroundSelector from './MobileBackgroundSelector.vue'
|
||||||
import ComponentWrapper from '@/components/data-visualization/canvas/ComponentWrapper.vue'
|
import ComponentWrapper from '@/components/data-visualization/canvas/ComponentWrapper.vue'
|
||||||
@ -47,17 +46,6 @@ const iframeSrc = computed(() => {
|
|||||||
? `${embeddedStore.baseUrl}mobile.html#/panel`
|
? `${embeddedStore.baseUrl}mobile.html#/panel`
|
||||||
: './mobile.html#/panel'
|
: './mobile.html#/panel'
|
||||||
})
|
})
|
||||||
const openHandler = ref(null)
|
|
||||||
|
|
||||||
const initOpenHandler = newWindow => {
|
|
||||||
if (openHandler?.value && !!embeddedStore.baseUrl) {
|
|
||||||
const pm = {
|
|
||||||
methodName: 'initOpenHandler',
|
|
||||||
args: newWindow
|
|
||||||
}
|
|
||||||
openHandler.value.invokeMethod(pm)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleLoad = () => {
|
const handleLoad = () => {
|
||||||
mobileStatusChange(
|
mobileStatusChange(
|
||||||
@ -146,7 +134,6 @@ const setMobileStyle = debounce(() => {
|
|||||||
transformOrigin: '0 0'
|
transformOrigin: '0 0'
|
||||||
}
|
}
|
||||||
}, 100)
|
}, 100)
|
||||||
const newWindow = ref()
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
window.addEventListener('message', hanedleMessage)
|
window.addEventListener('message', hanedleMessage)
|
||||||
window.addEventListener('resize', setMobileStyle)
|
window.addEventListener('resize', setMobileStyle)
|
||||||
@ -158,9 +145,6 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
setMobileStyle()
|
setMobileStyle()
|
||||||
setTimeout(() => {
|
|
||||||
initOpenHandler(newWindow.value)
|
|
||||||
}, 300)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@ -230,7 +214,7 @@ const save = () => {
|
|||||||
{{ dvInfo.name }}
|
{{ dvInfo.name }}
|
||||||
</div>
|
</div>
|
||||||
<div class="config-panel-content" v-loading="mobileLoading">
|
<div class="config-panel-content" v-loading="mobileLoading">
|
||||||
<iframe ref="newWindow" :src="iframeSrc" frameborder="0" width="375" />
|
<iframe :src="iframeSrc" frameborder="0" width="375" />
|
||||||
</div>
|
</div>
|
||||||
<div class="config-panel-foot"></div>
|
<div class="config-panel-foot"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -274,7 +258,6 @@ const save = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<XpackComponent ref="openHandler" jsname="L2NvbXBvbmVudC9lbWJlZGRlZC1pZnJhbWUvT3BlbkhhbmRsZXI=" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onBeforeMount, ref, onBeforeUnmount } from 'vue'
|
import { onBeforeMount, ref, onBeforeUnmount } from 'vue'
|
||||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||||
import { XpackComponent } from '@/components/plugin'
|
|
||||||
import eventBus from '@/utils/eventBus'
|
import eventBus from '@/utils/eventBus'
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import DePreviewMobile from './MobileInPc.vue'
|
import DePreviewMobile from './MobileInPc.vue'
|
||||||
@ -90,10 +89,7 @@ const hanedleMessage = event => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let p = null
|
|
||||||
const XpackLoaded = () => p(true)
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
await new Promise(r => (p = r))
|
|
||||||
window.top.postMessage({ type: 'panelInit', value: true }, '*')
|
window.top.postMessage({ type: 'panelInit', value: true }, '*')
|
||||||
window.addEventListener('message', hanedleMessage)
|
window.addEventListener('message', hanedleMessage)
|
||||||
useEmitt({
|
useEmitt({
|
||||||
@ -120,11 +116,6 @@ onBeforeUnmount(() => {
|
|||||||
<div class="panel-mobile">
|
<div class="panel-mobile">
|
||||||
<de-preview-mobile v-if="panelInit"></de-preview-mobile>
|
<de-preview-mobile v-if="panelInit"></de-preview-mobile>
|
||||||
</div>
|
</div>
|
||||||
<XpackComponent
|
|
||||||
jsname="L2NvbXBvbmVudC9lbWJlZGRlZC1pZnJhbWUvTmV3V2luZG93SGFuZGxlcg=="
|
|
||||||
@loaded="XpackLoaded"
|
|
||||||
@load-fail="XpackLoaded"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
Loading…
Reference in New Issue
Block a user