diff --git a/core/core-frontend/src/utils/communication.ts b/core/core-frontend/src/utils/communication.ts
deleted file mode 100644
index 1a0e32db1a..0000000000
--- a/core/core-frontend/src/utils/communication.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-export interface EmbeddedData {
- 'de-embedded': boolean
- embeddedToken?: string
- busiFlag?: string
- type?: string
- dvId?: string
- chartId?: string
- pid: string
-}
-
-export const communicationInit = cb => {
- window.addEventListener('message', event => {
- if (!event.data['de-embedded']) {
- return
- }
- const origin = event.origin
- console.log(origin)
- const embeddedData: EmbeddedData = event.data
- // validate origin
- if (cb) {
- cb(embeddedData)
- }
- })
- const readyData = {
- ready: true,
- msgOrigin: 'de-fit2cloud'
- }
- window.parent.postMessage(readyData, '*')
-}
-
-export const initOpenHandler = (newWindow, data) => {
- if (!data.embeddedToken) {
- return
- }
- window['uuid'] = new Date().getTime()
- newWindow['uuid'] = window['uuid'] + 1
- newWindow['name'] = 'de-new-resource-window'
- window.addEventListener('message', event => {
- if (
- event.data?.msgOrigin !== 'de-inner-fit2cloud' ||
- event.origin !== window.origin ||
- event.source['uuid'] !== newWindow['uuid']
- ) {
- return
- }
- data['de-inner-embedded'] = true
- if (event.data.ready) {
- newWindow.postMessage(data, '/')
- }
- })
-}
-
-export const newWindowReady = async cb => {
- return new Promise((resolve, reject) => {
- if (!window.opener || window['name'] !== 'de-new-resource-window') {
- return resolve(null)
- }
- window.addEventListener('message', event => {
- if (
- !event.data['de-inner-embedded'] ||
- event.origin !== window.origin ||
- window['uuid'] !== event.source['uuid'] - 1
- ) {
- return
- }
- if (cb) {
- cb(event.data)
- resolve(true)
- }
- })
- const readyData = {
- ready: true,
- msgOrigin: 'de-inner-fit2cloud'
- }
- window.opener.postMessage(readyData, '/')
- })
-}
diff --git a/core/core-frontend/src/views/chart/ChartView.vue b/core/core-frontend/src/views/chart/ChartView.vue
index 72bea1e486..6561206c5d 100644
--- a/core/core-frontend/src/views/chart/ChartView.vue
+++ b/core/core-frontend/src/views/chart/ChartView.vue
@@ -1,12 +1,7 @@
+
diff --git a/core/core-frontend/src/views/common/DeResourceTree.vue b/core/core-frontend/src/views/common/DeResourceTree.vue
index 016665426d..b3b523db23 100644
--- a/core/core-frontend/src/views/common/DeResourceTree.vue
+++ b/core/core-frontend/src/views/common/DeResourceTree.vue
@@ -16,11 +16,10 @@ const interactiveStore = interactiveStoreWithOut()
import router from '@/router'
import { useI18n } from '@/hooks/web/useI18n'
import _ from 'lodash'
-import DeResourceCreateOpt from '@/views/common/DeResourceCreateOpt.vue'
import DeResourceCreateOptV2 from '@/views/common/DeResourceCreateOptV2.vue'
import { useCache } from '@/hooks/web/useCache'
import { findParentIdByChildIdRecursive } from '@/utils/canvasUtils'
-import { initOpenHandler } from '@/utils/communication'
+import { XpackComponent } from '@/components/plugin'
const { wsCache } = useCache()
const dvMainStore = dvMainStoreWithOut()
@@ -277,7 +276,7 @@ const operation = (cmd: string, data: BusiTreeNode, nodeType: string) => {
? `#/dvCanvas?opt=copy&pid=${params.pid}&dvId=${data.data}`
: `#/dashboard?opt=copy&pid=${params.pid}&resourceId=${data.data}`
const newWindow = window.open(baseUrl, '_blank')
- initOpenHandler(newWindow, embeddedStore.getIframeData)
+ initOpenHandler(newWindow)
})
} else {
resourceGroupOpt.value.optInit(nodeType, data, cmd, ['copy'].includes(cmd))
@@ -300,7 +299,7 @@ const addOperation = (
} else {
newWindow = window.open(baseUrl, '_blank')
}
- initOpenHandler(newWindow, embeddedStore.getIframeData)
+ initOpenHandler(newWindow)
} else if (cmd === 'newFromTemplate') {
// state.templateCreatePid = data?.id
// // newFromTemplate
@@ -323,7 +322,7 @@ function createNewObject() {
const resourceEdit = resourceId => {
const baseUrl = curCanvasType.value === 'dataV' ? '#/dvCanvas?dvId=' : '#/dashboard?resourceId='
const newWindow = window.open(baseUrl + resourceId, '_blank')
- initOpenHandler(newWindow, embeddedStore.getIframeData)
+ initOpenHandler(newWindow)
}
const resourceOptFinish = () => {
@@ -343,7 +342,7 @@ const resourceCreateFinish = templateData => {
} else {
newWindow = window.open(baseUrl, '_blank')
}
- initOpenHandler(newWindow, embeddedStore.getIframeData)
+ initOpenHandler(newWindow)
}
const getParentKeys = (tree, targetKey, parentKeys = []) => {
@@ -375,6 +374,16 @@ watch(filterText, val => {
resourceListTree.value.filter(val)
})
+const openHandler = ref(null)
+const initOpenHandler = newWindow => {
+ if (openHandler?.value) {
+ const pm = {
+ methodName: 'initOpenHandler',
+ args: newWindow
+ }
+ openHandler.value.invokeMethod(pm)
+ }
+}
onMounted(() => {
getTree()
})
@@ -518,6 +527,7 @@ defineExpose({
>
+