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/9368
Vanessa6b036fbe75dc
diff --git a/app/electron/main.js b/app/electron/main.jsindex 16be4da4e8..da49292df8 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -655,15 +655,20 @@ app.whenReady().then(() => {resetTrayMenu(tray, lang, mainWindow);};-+ const getWindowByContentId = (id) => {+ return BrowserWindow.fromId(BrowserWindow.getAllWindows().find((win) => win.webContents.id === id).id)+ };ipcMain.on("siyuan-open-folder", (event, filePath) => {shell.showItemInFolder(filePath);});ipcMain.on("siyuan-first-quit", () => {app.exit();});- ipcMain.on("siyuan-show", (event, id) => {- showWindow(BrowserWindow.fromId(id));+ ipcMain.on("siyuan-show", (event) => {+ showWindow(getWindowByContentId(event.sender.id));+ });+ ipcMain.on("siyuan-hide", (event) => {+ getWindowByContentId(event.sender.id).hide();});ipcMain.on("siyuan-config-tray", (event, data) => {workspaces.find(item => {@@ -686,7 +691,7 @@ app.whenReady().then(() => {return;}data.filePaths = result.filePaths;- BrowserWindow.fromId(BrowserWindow.getAllWindows().find((win) => win.webContents.id === event.sender.id).id).getParentWindow().send("siyuan-export-pdf", data);+ getWindowByContentId(event.sender.id).getParentWindow().send("siyuan-export-pdf", data);});});ipcMain.on("siyuan-export-close", (event) => {@@ -781,7 +786,7 @@ app.whenReady().then(() => {// 系统托盘tray = new Tray(path.join(appDir, "stage", "icon-large.png"));tray.setToolTip(`${path.basename(data.workspaceDir)} - SiYuan v${appVer}`);- const mainWindow = BrowserWindow.fromId(BrowserWindow.getAllWindows().find((win) => win.webContents.id === event.sender.id).id);+ const mainWindow = getWindowByContentId(event.sender.id)resetTrayMenu(tray, data.languages, mainWindow);tray.on("click", () => {showHideWindow(tray, data.languages, mainWindow);diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.tsindex 46c150881c..79d768d194 100644--- a/app/src/boot/onGetConfig.ts+++ b/app/src/boot/onGetConfig.ts@@ -1,8 +1,8 @@import {exportLayout, JSONToLayout, resetLayout, resizeTopbar, resizeTabs} from "../layout/util";import {setStorageVal} from "../protyle/util/compatibility";/// #if !BROWSER-import {dialog, getCurrentWindow} from "@electron/remote";-import {ipcRenderer, OpenDialogReturnValue, webFrame} from "electron";+import {getCurrentWindow} from "@electron/remote";+import {ipcRenderer, webFrame} from "electron";import * as fs from "fs";import * as path from "path";import {afterExport} from "../protyle/export/util";@@ -282,7 +282,7 @@ export const initWindow = (app: App) => {action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],zoomIn: focus,});- ipcRenderer.send(Constants.SIYUAN_SHOW, getCurrentWindow().id);+ ipcRenderer.send(Constants.SIYUAN_SHOW);}app.plugins.forEach(plugin => {plugin.eventBus.emit("open-siyuan-url-block", {diff --git a/app/src/constants.ts b/app/src/constants.tsindex cca6bc1ca7..6e3b675ca7 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -25,6 +25,7 @@ export abstract class Constants {// 渲染进程调主进程public static readonly SIYUAN_SHOW: string = "siyuan-show";+ public static readonly SIYUAN_HIDE: string = "siyuan-hide";public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray";public static readonly SIYUAN_QUIT: string = "siyuan-quit";public static readonly SIYUAN_HOTKEY: string = "siyuan-hotkey";diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.tsindex 35aa704650..5581732c96 100644--- a/app/src/dialog/processSystem.ts+++ b/app/src/dialog/processSystem.ts@@ -5,7 +5,6 @@ import {exportLayout} from "../layout/util";/// #endif/// #if !BROWSERimport {ipcRenderer} from "electron";-import {getCurrentWindow} from "@electron/remote";/// #endifimport {hideMessage, showMessage} from "./message";import {Dialog} from "./index";@@ -200,7 +199,7 @@ export const exitSiYuan = () => {// 桌面端退出拉起更新安装时有时需要重启两次 https://github.com/siyuan-note/siyuan/issues/6544// 这里先将主界面隐藏setTimeout(() => {- getCurrentWindow().hide();+ ipcRenderer.send(Constants.SIYUAN_HIDE);}, 2000);// 然后等待一段时间后再退出,避免界面主进程退出以后内核子进程被杀死setTimeout(() => {