diff --git a/main.js b/main.js index b6b42f2..a7729e1 100644 --- a/main.js +++ b/main.js @@ -92,7 +92,15 @@ function createTray() { }, { label: '退出', click: async () => { - quit() + const url = mainWindow.webContents.getURL(); + const hash = new URL(url).hash; + if (hash.indexOf('/meeting') === -1) { + quit() + } else { + await mainWindow.webContents.send('quitAndInstall'); + mainWindow.show() + mainWindow.focus() + } }, // icon: iconPath, }, @@ -205,9 +213,12 @@ app.on('ready', () => { clipboard.writeText(text) }); // 退出 - ipcMain.handle('quit', async (event) => { - await mainWindow.webContents.send('quitAndInstall'); - quit() + ipcMain.handle('quit', async (event, bool) => { + if (bool) { + quit() + } else { + await mainWindow.webContents.send('quitAndInstall'); + } }); // 加入房间通知 ipcMain.handle('joinNotification', (event, user) => { diff --git a/preload.js b/preload.js index b68956c..9df37fc 100644 --- a/preload.js +++ b/preload.js @@ -38,8 +38,8 @@ window.electron = { ipcRenderer.on('onQuit', callback) }, // 退出房间 - quit: () => { - return ipcRenderer.invoke('quit') + quit: (bool) => { + return ipcRenderer.invoke('quit', bool) }, // 监听更新 onUpdate: (callback) => { diff --git a/src/App.tsx b/src/App.tsx index d39f593..ad304bb 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -103,7 +103,7 @@ const App: React.FC = () => { storage.setItem('setting', JSON.stringify(setting)) }) window.electron.quitAndInstall(async (_e: any) => { - leaveChannel() + storage.setItem('quitMeeting', true) }) }, []) useEffect(() => { @@ -138,14 +138,14 @@ const App: React.FC = () => { setIsState(false) window.electron.onQuit(async () => { if (location.hash.indexOf('/login') === 1) { - window.electron.quit() + window.electron.quit(location.hash.indexOf('/meeting') === -1) } else { if (storage.getItem('isTips') === 'true') { const setting = JSON.parse(storage.getItem('setting') as string) if (setting.closeSetting === 'hide') { window.electron.setViewStatus(setting.closeSetting) } else { - window.electron.quit() + window.electron.quit(location.hash.indexOf('/meeting') === -1) } } else { quitTipsRef.current.changeModal() diff --git a/src/components/QuitTips/index.tsx b/src/components/QuitTips/index.tsx index 6e0e8d1..3ace7e8 100644 --- a/src/components/QuitTips/index.tsx +++ b/src/components/QuitTips/index.tsx @@ -52,7 +52,7 @@ const QuitTips = forwardRef((props: any, ref: any) => {