From c76808939a43c12939902f166a3c34c71e88518e Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Thu, 17 Oct 2024 11:13:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=80=E5=87=BA=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 19 ++++++++++--- preload.js | 4 +-- src/App.tsx | 6 ++--- src/components/QuitTips/index.tsx | 2 +- src/page/Meeting/index.tsx | 45 ++++++++++++++++++++++++++++++- src/render.d.ts | 2 +- 6 files changed, 66 insertions(+), 12 deletions(-) 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) => {