From 3aaae78cb7a58b865a96e56aecc18f352851dae6 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 18 Mar 2023 23:54:58 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BD=BF=E7=94=A8=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=90=8C=E6=AD=A5=E7=9B=98=E6=97=B6=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=B9=B6=E9=80=80=E5=87=BA=E5=86=85=E6=A0=B8?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/7683?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index 463d7f432..477468126 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -61,23 +61,26 @@ try { // type: port/id const exitApp = (type, id) => { let tray; + let mainWindow; workspaces.find((item, index) => { if (type === "id") { if (item.id === id) { + mainWindow = item.browserWindow; if (workspaces.length > 1) { item.browserWindow.destroy(); - workspaces.splice(index, 1); } + workspaces.splice(index, 1); tray = item.tray; return true; } } else { const currentURL = new URL(item.browserWindow.getURL()); if (currentURL.port === id) { + mainWindow = item.browserWindow; if (workspaces.length > 1) { item.browserWindow.destroy(); - workspaces.splice(index, 1); } + workspaces.splice(index, 1); tray = item.tray; return true; } @@ -86,12 +89,11 @@ const exitApp = (type, id) => { if (tray && ("win32" === process.platform || "linux" === process.platform)) { tray.destroy(); } - if (workspaces.length === 1) { + if (workspaces.length === 0 && mainWindow) { try { if (resetWindowStateOnRestart) { fs.writeFileSync(windowStatePath, "{}"); } else { - const mainWindow = workspaces[0].browserWindow; const bounds = mainWindow.getBounds(); fs.writeFileSync(windowStatePath, JSON.stringify({ isMaximized: mainWindow.isMaximized(),