fix(X-Pack): 嵌入式-弹窗方式跳转报错缺失 Token

This commit is contained in:
fit2cloud-chenyw
2025-03-07 13:58:31 +08:00
committed by xuwei-fit2cloud
parent e8d2d32c42
commit 3b85c4bd69
2 changed files with 24 additions and 3 deletions

View File

@@ -20,11 +20,13 @@
/>
</div>
</el-dialog>
<XpackComponent ref="xpackIframe" jsname="L2NvbXBvbmVudC9lbWJlZGRlZC1pZnJhbWUvSWZyYW1lU2VsZg==" />
</template>
<script setup lang="ts">
import { computed, reactive } from 'vue'
import { computed, reactive, ref } from 'vue'
import { useEmbedded } from '@/store/modules/embedded'
import { XpackComponent } from '@/components/plugin'
const state = reactive({
dialogShow: false,
name: '',
@@ -33,7 +35,8 @@ const state = reactive({
width: '70vw',
height: '70%'
})
const xpackIframe = ref()
const embeddedStore = useEmbedded()
const dialogStyle = computed(() => {
if (state.fullscreen) {
return {}
@@ -60,6 +63,15 @@ const previewInit = params => {
state.height = '65%'
}
state.dialogShow = true
if (embeddedStore.getToken && state.url.includes('#/preview?dvId=')) {
if (xpackIframe?.value) {
const pm = {
methodName: 'iframeInit',
args: null
}
xpackIframe.value.invokeMethod(pm)
}
}
}
defineExpose({

View File

@@ -165,7 +165,9 @@ watch(
)
let p = null
let p1 = null
const XpackLoaded = () => p(true)
const initIframe = () => p1(true)
onMounted(async () => {
useEmitt({
name: 'canvasDownload',
@@ -174,6 +176,7 @@ onMounted(async () => {
}
})
await new Promise(r => (p = r))
await new Promise(r => (p1 = r))
const dvId = embeddedStore.dvId || router.currentRoute.value.query.dvId
// 检查外部参数
const ignoreParams = router.currentRoute.value.query.ignoreParams === 'true'
@@ -232,6 +235,12 @@ defineExpose({
@loaded="XpackLoaded"
@load-fail="XpackLoaded"
/>
<XpackComponent
jsname="L2NvbXBvbmVudC9lbWJlZGRlZC1pZnJhbWUvRW50cmFuY2Vz"
@init-iframe="initIframe"
@load-fail="initIframe"
/>
</template>
<style lang="less" scoped>