This commit is contained in:
yj 2024-08-15 11:06:29 +08:00
parent 92a3bb89a5
commit a9d2f4b1c7
1 changed files with 23 additions and 33 deletions

View File

@ -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,