An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/7708
Vanessab524a3c72f43
diff --git a/app/electron/main.js b/app/electron/main.jsindex 0bf22cf026..3dd4368fe7 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -51,31 +51,29 @@ try {}// type: port/id-const exitApp = (type, id, errorWindowId) => {+const exitApp = (port, errorWindowId) => {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);- tray = item.tray;- return true;++ // 关闭端口相同的所有非主窗口+ BrowserWindow.getAllWindows().forEach((item) => {+ const currentURL = new URL(item.getURL())+ if (port.toString() === currentURL.port.toString()) {+ if (currentURL.href.indexOf("/stage/build/app/?v=") > -1) {+ mainWindow = item;+ } else {+ item.destroy();}- } else {- const currentURL = new URL(item.browserWindow.getURL());- if (currentURL.port.toString() === id.toString()) {- mainWindow = item.browserWindow;- if (workspaces.length > 1) {- item.browserWindow.destroy();- }- workspaces.splice(index, 1);- tray = item.tray;- return true;+ }+ });+ workspaces.find((item, index) => {+ if (mainWindow.id === item.browserWindow.id) {+ if (workspaces.length > 1) {+ item.browserWindow.destroy();}+ workspaces.splice(index, 1);+ tray = item.tray;+ return true;}});if (tray && ("win32" === process.platform || "linux" === process.platform)) {@@ -103,7 +101,6 @@ const exitApp = (type, id, errorWindowId) => {if (errorWindowId) {BrowserWindow.getAllWindows().forEach((item) => {- writeLog(errorWindowId + " " + item.id);if (errorWindowId !== item.id) {item.destroy();}@@ -491,7 +488,7 @@ const initKernel = (workspace, port, lang) => {break;}- exitApp("port", currentKernelPort, errorWindowId);+ exitApp(currentKernelPort, errorWindowId);bootWindow.destroy();resolve(false);}@@ -666,8 +663,8 @@ app.whenReady().then(() => {shell.openExternal(url);});});- ipcMain.on("siyuan-quit", (event, id) => {- exitApp("id", id)+ ipcMain.on("siyuan-quit", (event, port) => {+ exitApp(port);});ipcMain.on("siyuan-openwindow", (event, data) => {const mainWindow = BrowserWindow.fromId(data.id);diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.tsindex fcfd6b24e3..1197fb3778 100644--- a/app/src/dialog/processSystem.ts+++ b/app/src/dialog/processSystem.ts@@ -111,7 +111,7 @@ export const exitSiYuan = () => {buttonElement.addEventListener("click", () => {fetchPost("/api/system/exit", {force: true}, () => {/// #if !BROWSER- ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);+ ipcRenderer.send(Constants.SIYUAN_QUIT, location.port);/// #elseif (["ios", "android"].includes(window.siyuan.config.system.container) && (window.webkit?.messageHandlers || window.JSAndroid)) {window.location.href = "siyuan://api/system/exit";@@ -135,7 +135,7 @@ export const exitSiYuan = () => {}, 2000);// 然后等待一段时间后再退出,避免界面主进程退出以后内核子进程被杀死setTimeout(() => {- ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);+ ipcRenderer.send(Constants.SIYUAN_QUIT, location.port);}, 4000);/// #endif});@@ -145,13 +145,13 @@ export const exitSiYuan = () => {execInstallPkg: 1 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装}, () => {/// #if !BROWSER- ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);+ ipcRenderer.send(Constants.SIYUAN_QUIT, location.port);/// #endif});});} else { // 正常退出/// #if !BROWSER- ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);+ ipcRenderer.send(Constants.SIYUAN_QUIT, location.port);/// #elseif (["ios", "android"].includes(window.siyuan.config.system.container) && (window.webkit?.messageHandlers || window.JSAndroid)) {window.location.href = "siyuan://api/system/exit";diff --git a/app/src/util/fetch.ts b/app/src/util/fetch.tsindex c4e547aba5..c21d6ee706 100644--- a/app/src/util/fetch.ts+++ b/app/src/util/fetch.ts@@ -49,7 +49,7 @@ export const fetchPost = (url: string, data?: any, cb?: (response: IWebSocketDatif (url === "/api/system/exit" || url === "/api/system/setWorkspaceDir" || (["/api/system/setUILayout"].includes(url) && data.errorExit // 内核中断,点关闭处理)) {- ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);+ ipcRenderer.send(Constants.SIYUAN_QUIT, location.port);}/// #endif});