This commit is contained in:
Vanessa 2023-03-21 18:16:20 +08:00
parent 1ab43ec9aa
commit 37e88627c0
2 changed files with 9 additions and 5 deletions

View file

@ -59,9 +59,13 @@ const exitApp = (port, errorWindowId) => {
try {
const currentURL = new URL(item.getURL());
if (port.toString() === currentURL.port.toString()) {
if (currentURL.href.indexOf("/stage/build/app/?v=") > -1) {
mainWindow = item;
} else {
const hasMain = workspaces.find((workspaceItem) => {
if (workspaceItem.browserWindow.id === item.id) {
mainWindow = item
return true;
}
})
if (!hasMain) {
item.destroy();
}
}
@ -70,7 +74,7 @@ const exitApp = (port, errorWindowId) => {
}
});
workspaces.find((item, index) => {
if (mainWindow.id === item.browserWindow.id) {
if (mainWindow && mainWindow.id === item.browserWindow.id) {
if (workspaces.length > 1) {
item.browserWindow.destroy();
}

View file

@ -437,7 +437,7 @@
try {
const {ipcRenderer} = require('electron')
const {getCurrentWindow} = require('@electron/remote')
ipcRenderer.send('siyuan-quit', getCurrentWindow().id)
ipcRenderer.send('siyuan-quit', location.port)
} catch (e) {
if ((window.webkit && window.webkit.messageHandlers) || window.JSAndroid) {
window.location.href = 'siyuan://api/system/exit'