diff --git a/src/App.tsx b/src/App.tsx index e9aa1c3..5b2f692 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,7 +9,7 @@ import Meeting from '@/page/Meeting/index' import NotFound from '@/page/NotFound/index' import { storage } from '@/utils' import { message, Spin } from "antd"; -import { onOtherSignalr, onReconnected, onStart, startSignalr } from "@/utils/package/signalr"; +import { onOtherSignalr, onReconnected, onStart, onStop, startSignalr } from "@/utils/package/signalr"; import JoinMeetingModal from "@/components/JoinMeetingModal"; import UpdateModal from "@/components/UpdateModal"; import * as CryptoJS from 'crypto-js'; @@ -121,7 +121,8 @@ const App: React.FC = () => { joinMeetingModalRef.current.changeModal(item) break; case 'ForceLogout': - await leaveChannel() + message.error(item.message) + await leaveChannel(true) toSrc('/login') break; } @@ -131,6 +132,7 @@ const App: React.FC = () => { useEffect(() => { try { if (location.hash.indexOf('/login') !== -1) { + onStop() window.electron.setMainWindowSize({ width: 752, height: 520, @@ -219,12 +221,14 @@ const App: React.FC = () => { } }; - const leaveChannel = async (): Promise => { + const leaveChannel = async (bool?: boolean): Promise => { if (location.hash.indexOf('/meeting') === 1) { const data = JSON.parse(localStorage.stateInfo); - await GetLeave({ - roomNum: data.channelId, - }) + if (!bool) { + await GetLeave({ + roomNum: data.channelId, + }) + } await agora.leaveChannel() } }; diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index cc34a21..2c4835b 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -9,7 +9,6 @@ import { } from "agora-electron-sdk"; import { GetRoomRtcToken } from "@/api/Home/Index"; import { storage } from '@/utils'; -import { onStop } from "./signalr"; const option: any = { appId: 'dcfc466a6ecb4a1f972630065dfb1e75', token: '', @@ -137,7 +136,6 @@ const agora = { stopAllEffect: true, stopMicrophoneRecording: true, }) - onStop() agora.stopScreenCapture() agora.release() }, diff --git a/src/utils/package/signalr.ts b/src/utils/package/signalr.ts index bb6d5d5..b8d0795 100644 --- a/src/utils/package/signalr.ts +++ b/src/utils/package/signalr.ts @@ -163,6 +163,7 @@ export const onInvoke = async (str: string, data: any) => { export const onStop = async () => { if (connection) { connection.stop() + connection = "" } }