Merge branch 'master' of https://gitea.23544.com/marking/WGShare.Client.Electron
This commit is contained in:
commit
3cfbd0da62
82
src/App.tsx
82
src/App.tsx
|
|
@ -9,7 +9,7 @@ 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 { message, Spin } from "antd";
|
import { message, Spin } from "antd";
|
||||||
import { onInvitation, onReconnected, onStart, startSignalr } from "@/utils/package/signalr";
|
import { onOtherSignalr, 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';
|
||||||
|
|
@ -32,19 +32,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);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function toLogin() {
|
|
||||||
try {
|
|
||||||
window.electron.setMainWindowSize({
|
|
||||||
width: 752,
|
|
||||||
height: 520,
|
|
||||||
key: 'login'
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
storage.removeItem('user')
|
|
||||||
navigate('/login')
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
|
|
@ -54,16 +41,17 @@ const App: React.FC = () => {
|
||||||
pwd: CryptoJS.MD5(loginInfo.password).toString(CryptoJS.enc.Hex)
|
pwd: CryptoJS.MD5(loginInfo.password).toString(CryptoJS.enc.Hex)
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
|
toSrc('/home')
|
||||||
startSignalr()
|
startSignalr()
|
||||||
} else {
|
} else {
|
||||||
toLogin()
|
toSrc('/login')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
toLogin()
|
toSrc('/login')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toLogin()
|
toSrc('/login')
|
||||||
}
|
}
|
||||||
if (import.meta.env.VITE_ENV !== 'development') {
|
if (import.meta.env.VITE_ENV !== 'development') {
|
||||||
document.addEventListener('keydown', (event) => {
|
document.addEventListener('keydown', (event) => {
|
||||||
|
|
@ -118,17 +106,12 @@ const App: React.FC = () => {
|
||||||
storage.setItem('setting', JSON.stringify(setting))
|
storage.setItem('setting', JSON.stringify(setting))
|
||||||
})
|
})
|
||||||
window.electron.quitAndInstall(async (_e: any) => {
|
window.electron.quitAndInstall(async (_e: any) => {
|
||||||
if (location.hash.indexOf('/meeting') === 1) {
|
leaveChannel()
|
||||||
const data = JSON.parse(localStorage.stateInfo);
|
|
||||||
await GetLeave({
|
|
||||||
roomNum: data.channelId,
|
|
||||||
})
|
|
||||||
await agora.leaveChannel()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onInvitation((item: any) => {
|
onOtherSignalr(async (item: any) => {
|
||||||
switch (item.key) {
|
switch (item.key) {
|
||||||
case 'Invitation':
|
case 'Invitation':
|
||||||
window.electron.joinNotification({
|
window.electron.joinNotification({
|
||||||
|
|
@ -137,9 +120,33 @@ const App: React.FC = () => {
|
||||||
})
|
})
|
||||||
joinMeetingModalRef.current.changeModal(item)
|
joinMeetingModalRef.current.changeModal(item)
|
||||||
break;
|
break;
|
||||||
|
case 'ForceLogout':
|
||||||
|
message.error(item.msg)
|
||||||
|
await leaveChannel()
|
||||||
|
toSrc('/login')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [navigate])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
if (location.hash.indexOf('/login') !== -1) {
|
||||||
|
window.electron.setMainWindowSize({
|
||||||
|
width: 752,
|
||||||
|
height: 520,
|
||||||
|
key: 'login'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
window.electron.setMainWindowSize({
|
||||||
|
width: 1200,
|
||||||
|
height: 800,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}, [location.hash])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onReconnected(async () => {
|
onReconnected(async () => {
|
||||||
storage.setItem('reconnect', true)
|
storage.setItem('reconnect', true)
|
||||||
|
|
@ -182,6 +189,7 @@ const App: React.FC = () => {
|
||||||
}
|
}
|
||||||
storage.setItem('stateInfo', JSON.stringify(state))
|
storage.setItem('stateInfo', JSON.stringify(state))
|
||||||
}, [state])
|
}, [state])
|
||||||
|
|
||||||
const handleResize = (): void => {
|
const handleResize = (): void => {
|
||||||
setWindowSize({
|
setWindowSize({
|
||||||
width: window.innerWidth,
|
width: window.innerWidth,
|
||||||
|
|
@ -195,6 +203,28 @@ const App: React.FC = () => {
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toSrc = (path: string): void => {
|
||||||
|
switch (path) {
|
||||||
|
case '/login':
|
||||||
|
storage.removeItem('user')
|
||||||
|
navigate('/login')
|
||||||
|
break;
|
||||||
|
case '/home':
|
||||||
|
navigate('/home')
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const leaveChannel = async (): Promise<void> => {
|
||||||
|
if (location.hash.indexOf('/meeting') === 1) {
|
||||||
|
const data = JSON.parse(localStorage.stateInfo);
|
||||||
|
await GetLeave({
|
||||||
|
roomNum: data.channelId,
|
||||||
|
})
|
||||||
|
await agora.leaveChannel()
|
||||||
|
}
|
||||||
|
};
|
||||||
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))
|
||||||
|
|
|
||||||
|
|
@ -894,7 +894,7 @@ const Meeting: React.FC = () => {
|
||||||
</div> : null}
|
</div> : null}
|
||||||
<Popover placement="bottom" title={''} content={
|
<Popover placement="bottom" title={''} content={
|
||||||
<div className={styles.meetingContentSwiperCardPopover}>
|
<div className={styles.meetingContentSwiperCardPopover}>
|
||||||
<Button
|
{user.roleId === '1' ? <Button
|
||||||
type="primary"
|
type="primary"
|
||||||
className='m-ant-btn'
|
className='m-ant-btn'
|
||||||
size={'small'}
|
size={'small'}
|
||||||
|
|
@ -902,7 +902,7 @@ const Meeting: React.FC = () => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
setAllUserLook(item)
|
setAllUserLook(item)
|
||||||
}}
|
}}
|
||||||
>全员看Ta</Button>
|
>全员看Ta</Button> : ''}
|
||||||
{item.uid !== user.uid ? <Button
|
{item.uid !== user.uid ? <Button
|
||||||
type="primary"
|
type="primary"
|
||||||
className='m-ant-btn'
|
className='m-ant-btn'
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,22 @@ export const onReconnected = async (callBack: Function) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const onInvitation = (callBack: Function) => {
|
export const onOtherSignalr = (callBack: Function) => {
|
||||||
if (connection) {
|
if (connection) {
|
||||||
|
// 邀请
|
||||||
connection.on("Invitation", (roomNum: string, roomName: string, InviterName: string) => {
|
connection.on("Invitation", (roomNum: string, roomName: string, InviterName: string) => {
|
||||||
callBack({
|
callBack({
|
||||||
key: 'Invitation',
|
key: 'Invitation',
|
||||||
roomNum, roomName, InviterName
|
roomNum, roomName, InviterName
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
// 退出
|
||||||
|
connection.on("ForceLogout", (msg: string) => {
|
||||||
|
callBack({
|
||||||
|
key: 'ForceLogout',
|
||||||
|
msg
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const onSignalr = (callBack: Function) => {
|
export const onSignalr = (callBack: Function) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue