diff --git a/src/App.tsx b/src/App.tsx index 9ebe593..fe4f490 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -31,7 +31,6 @@ 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) @@ -40,11 +39,32 @@ const App: React.FC = () => { PostLogin({ account: loginInfo.account, pwd: CryptoJS.MD5(loginInfo.password).toString(CryptoJS.enc.Hex) - }).then(res => { + }).then(async (res) => { if (res.code === 200) { storage.setItem('user', JSON.stringify(res.data)) toSrc('/home') - startSignalr() + await startSignalr() + 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; + } + }) + onReconnected(async () => { + storage.setItem('reconnect', true) + }) } else { toSrc('/login') } @@ -112,9 +132,6 @@ const App: React.FC = () => { }) }, []) useEffect(() => { - onReconnected(async () => { - storage.setItem('reconnect', true) - }) window.electron.onUpdate((_e: any, data: any) => { if (location.hash.indexOf('/meeting') === -1) { updateModalRef.current.changeModal(data) @@ -157,33 +174,6 @@ 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,