diff --git a/src/fox/index.tsx b/src/fox/index.tsx index 3bba3d0..2d54d14 100644 --- a/src/fox/index.tsx +++ b/src/fox/index.tsx @@ -8,6 +8,7 @@ import { defineComponent, onMounted, onUnmounted, ref, watch } from 'vue' import useRouterStore from '@/useRouterStore' import useSearchStore from '@/layout/header/search/useSearchStore' import useLayoutStore from '@/layout/useLayoutStore' +import { sendParent } from '@/utils/parent' const stageStrList = [ 'dazhaohu', @@ -128,6 +129,7 @@ export default defineComponent(() => { }} onClick={() => { run('aixin') + sendParent(['openSide']) }} /> ) diff --git a/src/utils/parent.ts b/src/utils/parent.ts new file mode 100644 index 0000000..b937712 --- /dev/null +++ b/src/utils/parent.ts @@ -0,0 +1,19 @@ +// 发送消息 +export function sendParent(data: ['openSide']) { + parent.window.postMessage( + { + type: data[0], + data: (data as any)[1] + }, + '*' + ) +} + +// 接收消息 +export function listenParent(type: string, cb: (data: T) => void) { + window.addEventListener('message', (e) => { + if (e.data?.type === 'uitab-' + type) { + cb(e.data.data) + } + }) +}