Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/7736

Vanessa37e88627c0da
diff --git a/app/electron/main.js b/app/electron/main.js
index 87a189755d..ea86256869 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -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();
}
diff --git a/app/stage/auth.html b/app/stage/auth.html
index 698e10c04b..e97107ee7c 100644
--- a/app/stage/auth.html
+++ b/app/stage/auth.html
@@ -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'