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/7683
Vanessac45cabfcdaf5
diff --git a/app/electron/main.js b/app/electron/main.jsindex 84cb32fc53..92b91590be 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -38,6 +38,7 @@ let bootWindow;let firstOpen = false;let workspaces = []; // workspaceDir, id, browserWindow, traylet kernelPort = 6806;+let resetWindowStateOnRestart = false;require("@electron/remote/main").initialize();if (!app.requestSingleInstanceLock()) {@@ -57,6 +58,60 @@ try {app.exit();}+// type: port/id+const exitApp = (type, id) => {+ let tray;+ workspaces.find((item, index) => {+ if (type === "id") {+ if (item.id === id) {+ if (workspaces.length > 1) {+ item.browserWindow.destroy();+ workspaces.splice(index, 1);+ }+ tray = item.tray;+ return true;+ }+ } else {+ const currentURL = new URL(item.browserWindow.getURL());+ if (currentURL.port === 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)) {+ tray.destroy();+ }+ if (workspaces.length === 1) {+ try {+ if (resetWindowStateOnRestart) {+ fs.writeFileSync(windowStatePath, "{}");+ } else {+ const mainWindow = workspaces[0].browserWindow;+ const bounds = mainWindow.getBounds();+ fs.writeFileSync(windowStatePath, JSON.stringify({+ isMaximized: mainWindow.isMaximized(),+ fullscreen: mainWindow.isFullScreen(),+ isDevToolsOpened: mainWindow.webContents.isDevToolsOpened(),+ x: bounds.x,+ y: bounds.y,+ width: bounds.width,+ height: bounds.height,+ }));+ }+ } catch (e) {+ writeLog(e);+ }+ app.exit();+ globalShortcut.unregisterAll();+ writeLog("exited ui");+ }+}+const getServer = (port = kernelPort) => {return "http://127.0.0.1:" + port;};@@ -497,7 +552,7 @@ const initKernel = (workspace, port, lang) => {<div>SiYuan Kernel exited for unknown reasons [code=${code}], please try to reboot your operating system and then start SiYuan again. If occurs this problem still, please check your anti-virus software whether kill the SiYuan Kernel.</div>`);break;}-+ exitApp("port", kernelPort);bootWindow.destroy();resolve(false);}@@ -583,8 +638,6 @@ app.commandLine.appendSwitch("enable-features", "PlatformHEVCDecoderSupport");app.setPath("userData", app.getPath("userData") + "-Electron"); // `~/.config` 下 Electron 相关文件夹名称改为 `SiYuan-Electron` https://github.com/siyuan-note/siyuan/issues/3349app.whenReady().then(() => {-- let resetWindowStateOnRestart = false;const resetTrayMenu = (tray, lang, mainWindow) => {const trayMenuTemplate = [{@@ -696,44 +749,7 @@ app.whenReady().then(() => {});});ipcMain.on("siyuan-quit", (event, id) => {- const mainWindow = BrowserWindow.fromId(id);- let tray;- workspaces.find((item, index) => {- if (item.id === id) {- if (workspaces.length > 1) {- mainWindow.destroy();- }- tray = item.tray;- workspaces.splice(index, 1);- return true;- }- });- if (tray && ("win32" === process.platform || "linux" === process.platform)) {- tray.destroy();- }- if (workspaces.length === 0) {- try {- if (resetWindowStateOnRestart) {- fs.writeFileSync(windowStatePath, "{}");- } else {- const bounds = mainWindow.getBounds();- fs.writeFileSync(windowStatePath, JSON.stringify({- isMaximized: mainWindow.isMaximized(),- fullscreen: mainWindow.isFullScreen(),- isDevToolsOpened: mainWindow.webContents.isDevToolsOpened(),- x: bounds.x,- y: bounds.y,- width: bounds.width,- height: bounds.height,- }));- }- } catch (e) {- writeLog(e);- }- app.exit();- globalShortcut.unregisterAll();- writeLog("exited ui");- }+ exitApp("id", id)});ipcMain.on("siyuan-openwindow", (event, data) => {const mainWindow = BrowserWindow.fromId(data.id);