退出优化
This commit is contained in:
parent
0a63a75574
commit
703596bd4a
3
main.js
3
main.js
|
|
@ -191,7 +191,8 @@ app.on('ready', () => {
|
||||||
clipboard.writeText(text)
|
clipboard.writeText(text)
|
||||||
});
|
});
|
||||||
// 退出
|
// 退出
|
||||||
ipcMain.handle('quit', (event) => {
|
ipcMain.handle('quit', async (event) => {
|
||||||
|
await mainWindow.webContents.send('quitAndInstall');
|
||||||
quit()
|
quit()
|
||||||
});
|
});
|
||||||
// 加入房间通知
|
// 加入房间通知
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ window.electron = {
|
||||||
onUpdate: (callback) => {
|
onUpdate: (callback) => {
|
||||||
ipcRenderer.on('update', callback)
|
ipcRenderer.on('update', callback)
|
||||||
},
|
},
|
||||||
|
// 执行退出房间
|
||||||
|
quitAndInstall: (callback) => {
|
||||||
|
ipcRenderer.on('quitAndInstall', callback)
|
||||||
|
},
|
||||||
// 通知下载最新的包
|
// 通知下载最新的包
|
||||||
onDownload: (type) => {
|
onDownload: (type) => {
|
||||||
ipcRenderer.invoke('updateDownload', type)
|
ipcRenderer.invoke('updateDownload', type)
|
||||||
|
|
|
||||||
16
src/App.tsx
16
src/App.tsx
|
|
@ -129,6 +129,15 @@ const App: React.FC = () => {
|
||||||
}
|
}
|
||||||
storage.setItem('setting', JSON.stringify(setting))
|
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(() => {
|
useEffect(() => {
|
||||||
onInvitation((item: any) => {
|
onInvitation((item: any) => {
|
||||||
|
|
@ -171,13 +180,6 @@ const App: React.FC = () => {
|
||||||
setIsState(false)
|
setIsState(false)
|
||||||
window.electron.onQuit(async () => {
|
window.electron.onQuit(async () => {
|
||||||
if (storage.getItem('isTips') === 'true') {
|
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()
|
window.electron.quit()
|
||||||
} else {
|
} else {
|
||||||
quitTipsRef.current.changeModal()
|
quitTipsRef.current.changeModal()
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ export interface IElectronAPI {
|
||||||
getSources: () => any;
|
getSources: () => any;
|
||||||
quit: () => any;
|
quit: () => any;
|
||||||
downFile: (callBack: Function) => void;
|
downFile: (callBack: Function) => void;
|
||||||
|
quitAndInstall: (callBack: Function) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue