This commit is contained in:
parent
52fd0e3410
commit
dcb857a163
53
src/App.tsx
53
src/App.tsx
|
|
@ -1,27 +1,25 @@
|
||||||
|
import {useEffect, useRef, useState} from "react";
|
||||||
import { useEffect, useState, useRef } from "react";
|
|
||||||
import '@/utils/styles/App.scss'
|
import '@/utils/styles/App.scss'
|
||||||
import { Route, Routes, useNavigate, Navigate, useLocation } from 'react-router-dom';
|
import {Navigate, Route, Routes, useLocation, useNavigate} from 'react-router-dom';
|
||||||
import Home from '@/page/Home/index'
|
import Home from '@/page/Home/index'
|
||||||
import Index from '@/page/Home/Index/index'
|
import Index from '@/page/Home/Index/index'
|
||||||
import User from '@/page/Home/User/index'
|
import User from '@/page/Home/User/index'
|
||||||
import Login from '@/page/Login/index'
|
import Login from '@/page/Login/index'
|
||||||
import Meeting from '@/page/Meeting/index'
|
import Meeting from '@/page/Meeting/index'
|
||||||
import NotFound from '@/page/NotFound/index'
|
import NotFound from '@/page/NotFound/index'
|
||||||
import { storage } from '@/utils'
|
import {storage} from '@/utils'
|
||||||
import { Spin, message } from "antd";
|
import {message, Spin} from "antd";
|
||||||
import { onInvitation, onInvoke, onReconnected, onStart } from "@/utils/package/signalr";
|
import {onInvitation, onInvoke, onReconnected, onStart, startSignalr} from "@/utils/package/signalr";
|
||||||
import JoinMeetingModal from "@/components/JoinMeetingModal";
|
import JoinMeetingModal from "@/components/JoinMeetingModal";
|
||||||
import UpdateModal from "@/components/UpdateModal";
|
import UpdateModal from "@/components/UpdateModal";
|
||||||
import * as CryptoJS from 'crypto-js';
|
import * as CryptoJS from 'crypto-js';
|
||||||
import { PostLogin } from "@/api/Login";
|
import {PostLogin} from "@/api/Login";
|
||||||
import { startSignalr } from '@/utils/package/signalr';
|
|
||||||
import agora from "@/utils/package/agora";
|
import agora from "@/utils/package/agora";
|
||||||
import QuitTips from "@/components/QuitTips";
|
import QuitTips from "@/components/QuitTips";
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { state } = useLocation();
|
const {state} = useLocation();
|
||||||
const joinMeetingModalRef = useRef<any>();
|
const joinMeetingModalRef = useRef<any>();
|
||||||
const updateModalRef = useRef<any>();
|
const updateModalRef = useRef<any>();
|
||||||
const quitTipsRef = useRef<any>();
|
const quitTipsRef = useRef<any>();
|
||||||
|
|
@ -39,19 +37,23 @@ const App: React.FC = () => {
|
||||||
height: 520,
|
height: 520,
|
||||||
key: 'login'
|
key: 'login'
|
||||||
})
|
})
|
||||||
} catch { }
|
} catch {
|
||||||
|
}
|
||||||
storage.removeItem('user')
|
storage.removeItem('user')
|
||||||
navigate('/login')
|
navigate('/login')
|
||||||
}
|
}
|
||||||
|
|
||||||
function toHome() {
|
function toHome() {
|
||||||
try {
|
try {
|
||||||
window.electron.setMainWindowSize({
|
window.electron.setMainWindowSize({
|
||||||
width: 1200,
|
width: 1200,
|
||||||
height: 800,
|
height: 800,
|
||||||
})
|
})
|
||||||
} catch { }
|
} catch {
|
||||||
|
}
|
||||||
navigate('/home')
|
navigate('/home')
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
if (userInfo) {
|
if (userInfo) {
|
||||||
|
|
@ -118,7 +120,7 @@ const App: React.FC = () => {
|
||||||
onReconnected(async () => {
|
onReconnected(async () => {
|
||||||
storage.setItem('reconnect', true)
|
storage.setItem('reconnect', true)
|
||||||
})
|
})
|
||||||
window.electron.onUpdate((data: any) => {
|
window.electron.onUpdate((e: any, data: any) => {
|
||||||
updateModalRef.current.changeModal(data)
|
updateModalRef.current.changeModal(data)
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
@ -147,7 +149,8 @@ const App: React.FC = () => {
|
||||||
const dom = document.getElementById('root') as HTMLElement;
|
const dom = document.getElementById('root') as HTMLElement;
|
||||||
dom.style.borderRadius = res ? '0px' : '10px'
|
dom.style.borderRadius = res ? '0px' : '10px'
|
||||||
})
|
})
|
||||||
} catch { }
|
} catch {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const handleCustomStorageChange = (e: any): void => {
|
const handleCustomStorageChange = (e: any): void => {
|
||||||
if (e.key === 'loading') {
|
if (e.key === 'loading') {
|
||||||
|
|
@ -170,20 +173,20 @@ const App: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path='/' element={<Home />} />
|
<Route path='/' element={<Home/>}/>
|
||||||
<Route path='/home' element={<Home />}>
|
<Route path='/home' element={<Home/>}>
|
||||||
<Route path='/home' element={<Navigate to='/home/index' />} />
|
<Route path='/home' element={<Navigate to='/home/index'/>}/>
|
||||||
<Route path='/home/index' element={<Index />} />
|
<Route path='/home/index' element={<Index/>}/>
|
||||||
<Route path='/home/user' element={<User />} />
|
<Route path='/home/user' element={<User/>}/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path='/login' element={<Login />} />
|
<Route path='/login' element={<Login/>}/>
|
||||||
<Route path='/meeting' element={<Meeting />} />
|
<Route path='/meeting' element={<Meeting/>}/>
|
||||||
<Route path='*' element={<NotFound />} />
|
<Route path='*' element={<NotFound/>}/>
|
||||||
</Routes>
|
</Routes>
|
||||||
<Spin spinning={spinning} fullscreen />
|
<Spin spinning={spinning} fullscreen/>
|
||||||
<JoinMeetingModal ref={joinMeetingModalRef} />
|
<JoinMeetingModal ref={joinMeetingModalRef}/>
|
||||||
<UpdateModal ref={updateModalRef} />
|
<UpdateModal ref={updateModalRef}/>
|
||||||
<QuitTips ref={quitTipsRef} />
|
<QuitTips ref={quitTipsRef}/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue