插件交互
This commit is contained in:
parent
34d37d4efd
commit
aa877662be
|
@ -8,6 +8,7 @@ import { defineComponent, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
import useRouterStore from '@/useRouterStore'
|
import useRouterStore from '@/useRouterStore'
|
||||||
import useSearchStore from '@/layout/header/search/useSearchStore'
|
import useSearchStore from '@/layout/header/search/useSearchStore'
|
||||||
import useLayoutStore from '@/layout/useLayoutStore'
|
import useLayoutStore from '@/layout/useLayoutStore'
|
||||||
|
import { sendParent } from '@/utils/parent'
|
||||||
|
|
||||||
const stageStrList = [
|
const stageStrList = [
|
||||||
'dazhaohu',
|
'dazhaohu',
|
||||||
|
@ -128,6 +129,7 @@ export default defineComponent(() => {
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
run('aixin')
|
run('aixin')
|
||||||
|
sendParent(['openSide'])
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// 发送消息
|
||||||
|
export function sendParent(data: ['openSide']) {
|
||||||
|
parent.window.postMessage(
|
||||||
|
{
|
||||||
|
type: data[0],
|
||||||
|
data: (data as any)[1]
|
||||||
|
},
|
||||||
|
'*'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 接收消息
|
||||||
|
export function listenParent<T>(type: string, cb: (data: T) => void) {
|
||||||
|
window.addEventListener('message', (e) => {
|
||||||
|
if (e.data?.type === 'uitab-' + type) {
|
||||||
|
cb(e.data.data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue