From 92a3bb89a561e5934090d9104e3c25d021bc0bcb Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Thu, 15 Aug 2024 10:53:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 3b3c3ad..9ebe593 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -31,6 +31,7 @@ const App: React.FC = () => { }); const [spinning, setSpinning] = useState(false); const [isState, setIsState] = useState(true); + const [isOnOtherSignalr, setIsOnOtherSignalr] = useState(true); useEffect(() => { let userInfo = JSON.parse(storage.getItem('user') as string) let loginInfo = JSON.parse(storage.getItem('login') as string) @@ -110,30 +111,6 @@ const App: React.FC = () => { leaveChannel() }) }, []) - - useEffect(() => { - setTimeout(() => { - onOtherSignalr(async (item: any) => { - switch (item.key) { - case 'Invitation': - window.electron.joinNotification({ - body: item.roomName, - name: item.InviterName, - }) - joinMeetingModalRef.current.changeModal(item) - break; - case 'ForceLogout': - if (item.message) { - message.error(item.message) - } - await leaveChannel(true) - toSrc('/login') - break; - } - }) - }, 3000); - }, []) - useEffect(() => { onReconnected(async () => { storage.setItem('reconnect', true) @@ -180,7 +157,33 @@ const App: React.FC = () => { } storage.setItem('stateInfo', JSON.stringify(state)) }, [state]) - + useEffect(() => { + if (location.hash.indexOf('/login') !== 1) { + if (isOnOtherSignalr) { + setIsOnOtherSignalr(false) + onOtherSignalr(async (item: any) => { + switch (item.key) { + case 'Invitation': + window.electron.joinNotification({ + body: item.roomName, + name: item.InviterName, + }) + joinMeetingModalRef.current.changeModal(item) + break; + case 'ForceLogout': + if (item.msg) { + message.error(item.msg) + } + await leaveChannel(true) + toSrc('/login') + break; + } + }) + } + } else { + setIsOnOtherSignalr(true) + } + }, [navigate]) const handleResize = (): void => { setWindowSize({ width: window.innerWidth,