This commit is contained in:
parent
1ef2e0cac1
commit
e7dccbba69
53
src/App.tsx
53
src/App.tsx
|
|
@ -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 [isSignalr, setIsSignalr] = 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)
|
||||||
|
|
@ -45,7 +44,6 @@ const App: React.FC = () => {
|
||||||
storage.setItem('user', JSON.stringify(res.data))
|
storage.setItem('user', JSON.stringify(res.data))
|
||||||
toSrc('/home')
|
toSrc('/home')
|
||||||
await startSignalr()
|
await startSignalr()
|
||||||
onEventSignalr()
|
|
||||||
} else {
|
} else {
|
||||||
toSrc('/login')
|
toSrc('/login')
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +151,6 @@ const App: React.FC = () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onEventSignalr()
|
|
||||||
storage.setItem('stateInfo', JSON.stringify(state))
|
storage.setItem('stateInfo', JSON.stringify(state))
|
||||||
}, [state])
|
}, [state])
|
||||||
const handleResize = (): void => {
|
const handleResize = (): void => {
|
||||||
|
|
@ -171,36 +168,32 @@ const App: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onEventSignalr = (): void => {
|
const onEventSignalr = (): void => {
|
||||||
if (isSignalr) {
|
onOtherSignalr(async (item: any) => {
|
||||||
setIsSignalr(false)
|
switch (item.key) {
|
||||||
onOtherSignalr(async (item: any) => {
|
case 'Invitation':
|
||||||
switch (item.key) {
|
window.electron.joinNotification({
|
||||||
case 'Invitation':
|
body: item.roomName,
|
||||||
window.electron.joinNotification({
|
name: item.InviterName,
|
||||||
body: item.roomName,
|
})
|
||||||
name: item.InviterName,
|
joinMeetingModalRef.current.changeModal(item)
|
||||||
})
|
break;
|
||||||
joinMeetingModalRef.current.changeModal(item)
|
case 'ForceLogout':
|
||||||
break;
|
if (item.msg) {
|
||||||
case 'ForceLogout':
|
message.error(item.msg)
|
||||||
if (item.msg) {
|
}
|
||||||
message.error(item.msg)
|
await leaveChannel(true)
|
||||||
}
|
toSrc('/login')
|
||||||
await leaveChannel(true)
|
break;
|
||||||
toSrc('/login')
|
}
|
||||||
break;
|
})
|
||||||
}
|
onReconnected(async () => {
|
||||||
})
|
storage.setItem('reconnect', true)
|
||||||
onReconnected(async () => {
|
})
|
||||||
storage.setItem('reconnect', true)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const toSrc = (path: string): void => {
|
const toSrc = (path: string): void => {
|
||||||
switch (path) {
|
switch (path) {
|
||||||
case '/login':
|
case '/login':
|
||||||
onStop()
|
onStop()
|
||||||
setIsSignalr(true)
|
|
||||||
window.electron.setMainWindowSize({
|
window.electron.setMainWindowSize({
|
||||||
width: 752,
|
width: 752,
|
||||||
height: 520,
|
height: 520,
|
||||||
|
|
@ -233,6 +226,10 @@ const App: React.FC = () => {
|
||||||
const handleCustomStorageChange = (e: any): void => {
|
const handleCustomStorageChange = (e: any): void => {
|
||||||
if (e.key === 'loading') {
|
if (e.key === 'loading') {
|
||||||
setSpinning(Boolean(e.value))
|
setSpinning(Boolean(e.value))
|
||||||
|
} else if (e.key === 'isSignalr') {
|
||||||
|
if (Boolean(e.value)) {
|
||||||
|
onEventSignalr()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export const startSignalr = async () => {
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
onStart()
|
onStart()
|
||||||
|
storage.setItem('isSignalr', true)
|
||||||
connection.onclose(async () => {
|
connection.onclose(async () => {
|
||||||
await onStart()
|
await onStart()
|
||||||
});
|
});
|
||||||
|
|
@ -162,6 +163,7 @@ export const onInvoke = async (str: string, data: any) => {
|
||||||
}
|
}
|
||||||
export const onStop = async () => {
|
export const onStop = async () => {
|
||||||
if (connection) {
|
if (connection) {
|
||||||
|
storage.setItem('isSignalr', false)
|
||||||
connection.off('Invitation');
|
connection.off('Invitation');
|
||||||
connection.off('ForceLogout');
|
connection.off('ForceLogout');
|
||||||
connection.stop()
|
connection.stop()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue