refactor(嵌入式): 完善嵌入内外交互

This commit is contained in:
wangjiahao 2024-05-28 19:11:09 +08:00
parent b7f8321cf1
commit 2ed0a2b36a
3 changed files with 12 additions and 9 deletions

View File

@ -246,9 +246,9 @@ const winMsgHandle = event => {
msgInfo.type === 'attachParams' &&
msgInfo.targetSourceId === dvInfo.value.id + ''
) {
const attachParam = msgInfo.params
if (attachParam) {
dvMainStore.addOuterParamsFilter(attachParam, componentData.value, 'outer')
const attachParams = msgInfo.params
if (attachParams) {
dvMainStore.addOuterParamsFilter(attachParams, componentData.value, 'outer')
}
}
}

View File

@ -39,7 +39,7 @@ onBeforeMount(async () => {
}
//
let attachParam
let attachParams
await getOuterParamsInfo(embeddedStore.dvId).then(rsp => {
dvMainStore.setNowPanelOuterParamsInfo(rsp.data)
})
@ -48,7 +48,7 @@ onBeforeMount(async () => {
if (embeddedStore.outerParams) {
try {
const outerPramsParse = JSON.parse(embeddedStore.outerParams)
attachParam = outerPramsParse.attachParam
attachParams = outerPramsParse.attachParams
dvMainStore.setEmbeddedCallBack(outerPramsParse.callBackFlag || 'no')
} catch (e) {
console.error(e)
@ -74,8 +74,8 @@ onBeforeMount(async () => {
nextTick(() => {
dashboardPreview.value.restore()
})
if (attachParam) {
dvMainStore.addOuterParamsFilter(attachParam, canvasDataResult, 'outer')
if (attachParams) {
dvMainStore.addOuterParamsFilter(attachParams, canvasDataResult, 'outer')
}
}
)

View File

@ -291,9 +291,12 @@ const onPointClick = param => {
type: 'de_inner_params',
sourceDvId: dvInfo.value.id,
sourceViewId: view.value.id,
message: Base64.encode(param)
message: Base64.encode(JSON.stringify(param))
}
if (window['dataease-embedded-host']) {
console.info('de_inner_params send to host')
window['dataease-embedded-host'].postMessage(msg, '*')
}
window.parent.postMessage(msg, '*')
} catch (e) {
console.warn('de_inner_params send error')
}