退出优化

This commit is contained in:
yj 2024-08-08 16:18:27 +08:00
parent 0a63a75574
commit 703596bd4a
4 changed files with 16 additions and 8 deletions

View File

@ -191,7 +191,8 @@ app.on('ready', () => {
clipboard.writeText(text)
});
// 退出
ipcMain.handle('quit', (event) => {
ipcMain.handle('quit', async (event) => {
await mainWindow.webContents.send('quitAndInstall');
quit()
});
// 加入房间通知

View File

@ -37,6 +37,10 @@ window.electron = {
onUpdate: (callback) => {
ipcRenderer.on('update', callback)
},
// 执行退出房间
quitAndInstall: (callback) => {
ipcRenderer.on('quitAndInstall', callback)
},
// 通知下载最新的包
onDownload: (type) => {
ipcRenderer.invoke('updateDownload', type)

View File

@ -129,6 +129,15 @@ const App: React.FC = () => {
}
storage.setItem('setting', JSON.stringify(setting))
})
window.electron.quitAndInstall(async (_e: any) => {
if (location.hash.indexOf('/meeting') === 1) {
const data = JSON.parse(localStorage.stateInfo);
await onInvoke('levelChannel', {
roomNum: data.channelId
})
await agora.leaveChannel()
}
})
}, [])
useEffect(() => {
onInvitation((item: any) => {
@ -171,13 +180,6 @@ const App: React.FC = () => {
setIsState(false)
window.electron.onQuit(async () => {
if (storage.getItem('isTips') === 'true') {
if (location.hash.indexOf('/meeting') !== -1) {
const data = JSON.parse(localStorage.stateInfo);
await onInvoke('levelChannel', {
roomNum: data.channelId
})
await agora.leaveChannel()
}
window.electron.quit()
} else {
quitTipsRef.current.changeModal()

1
src/render.d.ts vendored
View File

@ -13,6 +13,7 @@ export interface IElectronAPI {
getSources: () => any;
quit: () => any;
downFile: (callBack: Function) => void;
quitAndInstall: (callBack: Function) => void;
}
declare global {