From 96bbfbc927f012033bc0212ffe909aed438de7b6 Mon Sep 17 00:00:00 2001 From: cf-erp Date: Mon, 8 Apr 2024 07:54:21 +0000 Subject: [PATCH] =?UTF-8?q?!2662=20=E5=8A=9F=E8=83=BD:cad=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=A2=9E=E5=8A=A0=E4=BC=98=E5=8C=96=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/Erp/JumpView.tsx | 68 +++++++++++++++++++ src/UI/Components/MainContent/Content.tsx | 33 +++++++-- .../Components/MainContent/MainContent.less | 5 ++ 3 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 src/Add-on/Erp/JumpView.tsx diff --git a/src/Add-on/Erp/JumpView.tsx b/src/Add-on/Erp/JumpView.tsx new file mode 100644 index 000000000..3baa7f19b --- /dev/null +++ b/src/Add-on/Erp/JumpView.tsx @@ -0,0 +1,68 @@ +import * as React from "react"; +import { forwardRef, useEffect } from "react"; +import { app } from "../../ApplicationServices/Application"; +import { StoreageKeys } from "../../Common/StoreageKeys"; +import { ErpURL } from "./HostURL"; +interface JumpProp +{ + routeName: string; + routeParams: object; +} +const JumpView: React.FC = forwardRef((props) => +{ + const iframe = React.createRef(); + const loadedEvent = (ev) => + { + if (ev.data.command == 'loaded') + { + iframe.current.contentWindow.postMessage( + { + command: 'jumpUrl', + content: { + route: { name: props.routeName, params: props.routeParams }, + session: localStorage.getItem(StoreageKeys.PlatSession), + token: localStorage.getItem(StoreageKeys.PlatToken), + }, + }, + "*" + ); + } + }; + const closeEvent = (ev) => + { + if (ev.data.command == 'close') + { + app.Editor.ModalManage.Destory(); + } + + }; + useEffect(() => + { + window.addEventListener('message', loadedEvent); + window.addEventListener('message', closeEvent); + setTimeout(() => + { + window.removeEventListener('message', loadedEvent); + window.removeEventListener('message', closeEvent); + app.Editor.ModalManage.Destory(); + + }, 1000); + return () => + { + window.removeEventListener('message', loadedEvent); + window.removeEventListener('message', closeEvent); + }; + }); + const includes = ErpURL.host.includes('?'); + const url = ErpURL.host.replace(/\/$/, '') + `${includes ? '&' : '/?'}stamp=${new Date().getTime()}#/` + 'openUrl'; + return ( +