Compare commits
2 Commits
3d352a5d36
...
2be8ac3711
| Author | SHA1 | Date |
|---|---|---|
|
|
2be8ac3711 | |
|
|
f635bb58cc |
|
|
@ -51,7 +51,7 @@ const Home: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const user = JSON.parse(storage.getItem('user') as string);
|
const user = JSON.parse(storage.getItem('user') as string);
|
||||||
setUserInfo(user)
|
setUserInfo(user)
|
||||||
startSignalr()
|
startSignalr(() => { })
|
||||||
const updateTime = () => {
|
const updateTime = () => {
|
||||||
setDateInfo({
|
setDateInfo({
|
||||||
work: dayjs().format('ddd'),
|
work: dayjs().format('ddd'),
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { GetRoomFile, PostRoomFile, DeleteRoomFile, GetRoomUpFileurl, GetRoomFil
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import ImageUrl from '@/utils/package/imageUrl'
|
import ImageUrl from '@/utils/package/imageUrl'
|
||||||
import agora from '@/utils/package/agora'
|
import agora from '@/utils/package/agora'
|
||||||
import { onInvoke, onSignalr, offSignalr } from '@/utils/package/signalr';
|
import { onInvoke, onSignalr, offSignalr, startSignalr } from '@/utils/package/signalr';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import durationPlugin from 'dayjs/plugin/duration';
|
import durationPlugin from 'dayjs/plugin/duration';
|
||||||
import { VideoSourceType } from 'agora-electron-sdk';
|
import { VideoSourceType } from 'agora-electron-sdk';
|
||||||
|
|
@ -172,6 +172,8 @@ const Meeting: React.FC = () => {
|
||||||
setUser(userInfo)
|
setUser(userInfo)
|
||||||
setIsInit(false)
|
setIsInit(false)
|
||||||
window.addEventListener('customStorageChange', handleCustomStorageChange);
|
window.addEventListener('customStorageChange', handleCustomStorageChange);
|
||||||
|
window.addEventListener('online', handleNetworkChange);
|
||||||
|
window.addEventListener('offline', handleNetworkChange);
|
||||||
time = setInterval(() => {
|
time = setInterval(() => {
|
||||||
let effectiveTypeLength = ['slow-2g', '2g', '3g', '4g'].indexOf((navigator as any).connection.effectiveType)
|
let effectiveTypeLength = ['slow-2g', '2g', '3g', '4g'].indexOf((navigator as any).connection.effectiveType)
|
||||||
if (effectiveTypeLength >= 0) {
|
if (effectiveTypeLength >= 0) {
|
||||||
|
|
@ -184,6 +186,8 @@ const Meeting: React.FC = () => {
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('customStorageChange', handleCustomStorageChange);
|
window.removeEventListener('customStorageChange', handleCustomStorageChange);
|
||||||
|
window.removeEventListener('online', handleNetworkChange);
|
||||||
|
window.removeEventListener('offline', handleNetworkChange);
|
||||||
clearInterval(time)
|
clearInterval(time)
|
||||||
};
|
};
|
||||||
}, [fileList.pageIndex]);
|
}, [fileList.pageIndex]);
|
||||||
|
|
@ -241,8 +245,24 @@ const Meeting: React.FC = () => {
|
||||||
|
|
||||||
}, [currentVideoId])
|
}, [currentVideoId])
|
||||||
|
|
||||||
|
// 网络
|
||||||
|
const handleNetworkChange = (): void => {
|
||||||
|
if (navigator.onLine) {
|
||||||
|
message.success('网络已恢复。')
|
||||||
|
startSignalr(async () => {
|
||||||
|
await onInvoke('joinChannel', {
|
||||||
|
roomNum: state.channelId,
|
||||||
|
enableMicr: true,
|
||||||
|
enableCamera: true
|
||||||
|
})
|
||||||
|
await getRoomUser()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
message.error('网络已断开!')
|
||||||
|
}
|
||||||
|
}
|
||||||
// 加入房间时间
|
// 加入房间时间
|
||||||
const changeCurrentSeconds = () => {
|
const changeCurrentSeconds = (): string => {
|
||||||
const duration = dayjs.duration(currentSeconds, 'seconds');
|
const duration = dayjs.duration(currentSeconds, 'seconds');
|
||||||
const hours = duration.hours(); // 整数小时
|
const hours = duration.hours(); // 整数小时
|
||||||
const minutes = duration.minutes(); // 整数分钟
|
const minutes = duration.minutes(); // 整数分钟
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import * as signalR from '@microsoft/signalr';
|
import * as signalR from '@microsoft/signalr';
|
||||||
import storage from './storage';
|
import storage from './storage';
|
||||||
let connection = null as any;
|
let connection = null as any;
|
||||||
export const startSignalr = async () => {
|
export const startSignalr = async (callBack: Function) => {
|
||||||
const user = await JSON.parse(storage.getItem('user') as string);
|
const user = await JSON.parse(storage.getItem('user') as string);
|
||||||
connection = new signalR.HubConnectionBuilder().withAutomaticReconnect()
|
connection = new signalR.HubConnectionBuilder().withAutomaticReconnect()
|
||||||
.withUrl(`${import.meta.env.VITE_BASE_URL_API}/session-manage`, {
|
.withUrl(`${import.meta.env.VITE_BASE_URL_API}/session-manage`, {
|
||||||
|
|
@ -12,8 +12,8 @@ export const startSignalr = async () => {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
connection.start()
|
connection.start()
|
||||||
.then(() => console.log('Connection started!'))
|
.then(() => callBack())
|
||||||
.catch((err: any) => setTimeout(()=> startSignalr(), 5000));
|
.catch((err: any) => setTimeout(() => startSignalr(() => { }), 5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const onInvitation = (callBack: Function) => {
|
export const onInvitation = (callBack: Function) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue