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 [spinning, setSpinning] = useState(false);
const [isState, setIsState] = useState(true); const [isState, setIsState] = useState(true);
const [isOnOtherSignalr, setIsOnOtherSignalr] = useState(true);
useEffect(() => { useEffect(() => {
let userInfo = JSON.parse(storage.getItem('user') as string) let userInfo = JSON.parse(storage.getItem('user') as string)
let loginInfo = JSON.parse(storage.getItem('login') as string) let loginInfo = JSON.parse(storage.getItem('login') as string)
@ -40,11 +39,32 @@ const App: React.FC = () => {
PostLogin({ PostLogin({
account: loginInfo.account, account: loginInfo.account,
pwd: CryptoJS.MD5(loginInfo.password).toString(CryptoJS.enc.Hex) pwd: CryptoJS.MD5(loginInfo.password).toString(CryptoJS.enc.Hex)
}).then(res => { }).then(async (res) => {
if (res.code === 200) { if (res.code === 200) {
storage.setItem('user', JSON.stringify(res.data)) storage.setItem('user', JSON.stringify(res.data))
toSrc('/home') 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 { } else {
toSrc('/login') toSrc('/login')
} }
@ -112,9 +132,6 @@ const App: React.FC = () => {
}) })
}, []) }, [])
useEffect(() => { useEffect(() => {
onReconnected(async () => {
storage.setItem('reconnect', true)
})
window.electron.onUpdate((_e: any, data: any) => { window.electron.onUpdate((_e: any, data: any) => {
if (location.hash.indexOf('/meeting') === -1) { if (location.hash.indexOf('/meeting') === -1) {
updateModalRef.current.changeModal(data) updateModalRef.current.changeModal(data)
@ -157,33 +174,6 @@ const App: React.FC = () => {
} }
storage.setItem('stateInfo', JSON.stringify(state)) storage.setItem('stateInfo', JSON.stringify(state))
}, [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 => { const handleResize = (): void => {
setWindowSize({ setWindowSize({
width: window.innerWidth, width: window.innerWidth,