From 5bd6bb8925ff65d3829b1289e25df2e79ffbe11d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 7 Feb 2023 17:35:53 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=80=9A=E8=BF=87=20`Alt+M`=20?= =?UTF-8?q?=E6=9C=80=E5=B0=8F=E5=8C=96=E5=90=8E=E7=84=A6=E7=82=B9=E5=9B=9E?= =?UTF-8?q?=E5=88=B0=E5=85=88=E5=89=8D=E7=9A=84=E7=AA=97=E5=8F=A3=20Fix=20?= =?UTF-8?q?https://github.com/siyuan-note/siyuan/issues/7275?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index d30bc3446..eaf4b5b73 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -635,6 +635,12 @@ app.whenReady().then(() => { tray.setContextMenu(contextMenu) } + const hideWindow = (wnd) => { + // 通过 `Alt+M` 最小化后焦点回到先前的窗口 https://github.com/siyuan-note/siyuan/issues/7275 + wnd.minimize() + wnd.hide() + } + const showHideWindow = (tray, lang, mainWindow) => { if (!mainWindow.isVisible()) { if (mainWindow.isMinimized()) { @@ -642,7 +648,7 @@ app.whenReady().then(() => { } mainWindow.show() } else { - mainWindow.hide() + hideWindow(mainWindow) } resetTrayMenu(tray, lang, mainWindow) @@ -657,7 +663,7 @@ app.whenReady().then(() => { ipcMain.on('siyuan-config-tray', (event, data) => { workspaces.find(item => { if (item.id === data.id) { - item.browserWindow.hide() + hideWindow(item.browserWindow) if ('win32' === process.platform || 'linux' === process.platform) { resetTrayMenu(item.tray, data.languages, item.browserWindow) } @@ -814,10 +820,10 @@ app.whenReady().then(() => { if (!mainWindow.isFocused()) { mainWindow.show() } else { - mainWindow.hide() + hideWindow(mainWindow) } } else { - mainWindow.hide() + hideWindow(mainWindow) } } else { mainWindow.show()