|
@@ -1,57 +1,11 @@
|
|
/*
|
|
/*
|
|
* @Author: your name
|
|
* @Author: your name
|
|
* @Date: 2021-12-21 11:05:37
|
|
* @Date: 2021-12-21 11:05:37
|
|
- * @LastEditTime: 2021-12-22 09:02:37
|
|
|
|
|
|
+ * @LastEditTime: 2022-01-06 11:24:06
|
|
* @LastEditors: Please set LastEditors
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
* @FilePath: /KC-MiddlePlatform/src/global.tsx
|
|
* @FilePath: /KC-MiddlePlatform/src/global.tsx
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
-import {history } from 'umi';
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- window.stateFromTop = { //挂载通信数据
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // window.addEventListener('message',event=>{
|
|
|
|
- // if(event.origin == 'http://localhost:8804'){
|
|
|
|
- // console.log({event});
|
|
|
|
- // window.stateFromTop = {
|
|
|
|
- // ...event
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
-
|
|
|
|
- window.postMessageToChild = async (data)=>{ //添加全局postMessageToChild函数
|
|
|
|
- const iframes = document.getElementsByClassName('iframe');
|
|
|
|
- Array.from(iframes).forEach((iframe) => {
|
|
|
|
- const iframeWindow = iframe as HTMLIFrameElement;
|
|
|
|
- if(iframeWindow&&iframeWindow.contentWindow){
|
|
|
|
- iframeWindow.contentWindow.postMessage({...data},'http://localhost:8804')
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- // window.postMessage({...data},'http://localhost:8804')
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- window.removeListenner = async (handlerName:string)=>{
|
|
|
|
- console.log({handlerName});
|
|
|
|
- window.removeEventListener('handlerName',()=>{
|
|
|
|
- console.log('remove message listener');
|
|
|
|
- });
|
|
|
|
- // window.postMessage({...data},'http://localhost:8804')
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- window.addEventListener('message',(event)=>{
|
|
|
|
- if (event.origin === "http://localhost:8804"){
|
|
|
|
- console.log(event.data);
|
|
|
|
- if(event.data.type == 'LOGOUT'){
|
|
|
|
- window.removeListenner('message');
|
|
|
|
- history.replace('/login');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }, false);
|
|
|
|
|
|
+import { history } from 'umi';
|