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/7500
Vanessa8713734ba97b
diff --git a/app/electron/main.js b/app/electron/main.jsindex c06e9798b3..38cff7cce4 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -841,14 +841,9 @@ app.whenReady().then(() => {});});});- ipcMain.on("siyuan-lock-screen", () => {+ ipcMain.on("siyuan-send_windows", (event, data) => {BrowserWindow.getAllWindows().forEach(item => {- item.webContents.send("siyuan-lock-screen");- });- });- ipcMain.on("siyuan-closetab", (event, data) => {- BrowserWindow.getAllWindows().forEach(item => {- item.webContents.send("siyuan-closetab", data);+ item.webContents.send("siyuan-send_windows", data);});});diff --git a/app/src/constants.ts b/app/src/constants.tsindex 8eda7330c5..c44803a0d1 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -22,7 +22,6 @@ export abstract class Constants {// 渲染进程调主进程public static readonly SIYUAN_SHOW: string = "siyuan-show";- public static readonly SIYUAN_LOCK_SCREEN: string = "siyuan-lock-screen";public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray";public static readonly SIYUAN_OPEN_WORKSPACE: string = "siyuan-open-workspace";public static readonly SIYUAN_QUIT: string = "siyuan-quit";@@ -30,7 +29,7 @@ export abstract class Constants {public static readonly SIYUAN_INIT: string = "siyuan-init";public static readonly SIYUAN_OPENURL: string = "siyuan-openurl";public static readonly SIYUAN_OPENWINDOW: string = "siyuan-openwindow";- public static readonly SIYUAN_CLOSETAB: string = "siyuan-closetab";+ public static readonly SIYUAN_SEND_WINDOWS: string = "siyuan-send_windows"; // 主窗口和各新窗口之间的通信,{cmd: "closetab"|"lockscreen", data: {}})public static readonly SIYUAN_SAVE_CLOSE: string = "siyuan-save-close";public static readonly SIYUAN_EXPORT_PDF: string = "siyuan-export-pdf";public static readonly SIYUAN_EXPORT_CLOSE: string = "siyuan-export-close";diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.tsindex 5646e8f170..94b28ce415 100644--- a/app/src/dialog/processSystem.ts+++ b/app/src/dialog/processSystem.ts@@ -19,10 +19,10 @@ import {needSubscribe} from "../util/needSubscribe";export const lockScreen = () => {/// #if BROWSERfetchPost("/api/system/logoutAuth", {}, () => {- window.location.href = "/";+ window.location.href = `/check-auth?url=${window.location.href}`;});/// #else- ipcRenderer.send(Constants.SIYUAN_LOCK_SCREEN);+ ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "lockscreen"});/// #endif};diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.tsindex d0e955db58..b0d7ad385c 100644--- a/app/src/layout/Wnd.ts+++ b/app/src/layout/Wnd.ts@@ -223,7 +223,7 @@ export class Wnd {if (wnd instanceof Wnd) {JSONToCenter(tabData, wnd);oldTab = wnd.children[wnd.children.length - 1];- ipcRenderer.send(Constants.SIYUAN_CLOSETAB, tabData.id);+ ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});it.querySelector("li[data-clone='true']").remove();wnd.switchTab(oldTab.headElement);}@@ -331,7 +331,7 @@ export class Wnd {if (!oldTab) { // 从主窗口拖拽到页签新窗口JSONToCenter(tabData, this);oldTab = this.children[this.children.length - 1];- ipcRenderer.send(Constants.SIYUAN_CLOSETAB, tabData.id);+ ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});}/// #endifif (!oldTab) {diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.tsindex 44d6acae2f..9cef4f717a 100644--- a/app/src/util/globalShortcut.ts+++ b/app/src/util/globalShortcut.ts@@ -89,9 +89,11 @@ const switchDialogEvent = (event: MouseEvent, switchDialog: Dialog) => {export const globalShortcut = () => {document.body.addEventListener("mouseleave", () => {- window.siyuan.layout.leftDock.hideDock();- window.siyuan.layout.rightDock.hideDock();- window.siyuan.layout.bottomDock.hideDock();+ if (window.siyuan.layout.leftDock) {+ window.siyuan.layout.leftDock.hideDock();+ window.siyuan.layout.rightDock.hideDock();+ window.siyuan.layout.bottomDock.hideDock();+ }});window.addEventListener("mousemove", (event: MouseEvent & { target: HTMLElement }) => {if (window.siyuan.hideBreadcrumb) {@@ -837,7 +839,7 @@ export const globalShortcut = () => {}// dock float 时,点击空白处,隐藏 dockconst floatDockLayoutElement = hasClosestByClassName(event.target, "layout--float", true);- if (floatDockLayoutElement) {+ if (floatDockLayoutElement && window.siyuan.layout.leftDock) {if (!floatDockLayoutElement.isSameNode(window.siyuan.layout.bottomDock.layout.element)) {window.siyuan.layout.bottomDock.hideDock();}@@ -847,7 +849,7 @@ export const globalShortcut = () => {if (!floatDockLayoutElement.isSameNode(window.siyuan.layout.rightDock.layout.element)) {window.siyuan.layout.rightDock.hideDock();}- } else if (!hasClosestByClassName(event.target, "dock") && !isWindow()) {+ } else if (!hasClosestByClassName(event.target, "dock") && !isWindow() && window.siyuan.layout.leftDock) {window.siyuan.layout.bottomDock.hideDock();window.siyuan.layout.leftDock.hideDock();window.siyuan.layout.rightDock.hideDock();diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.tsindex 921244ab27..aa6b91c8a3 100644--- a/app/src/util/onGetConfig.ts+++ b/app/src/util/onGetConfig.ts@@ -1,5 +1,5 @@import {openSearch} from "../search/spread";-import {exportLayout, getInstanceById, JSONToLayout, resetLayout, resizeDrag, resizeTabs} from "../layout/util";+import {exportLayout, JSONToLayout, resetLayout, resizeDrag, resizeTabs} from "../layout/util";import {hotKey2Electron, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";/// #if !BROWSERimport {dialog, getCurrentWindow} from "@electron/remote";@@ -7,6 +7,7 @@ import {ipcRenderer, OpenDialogReturnValue, webFrame} from "electron";import * as fs from "fs";import * as path from "path";import {afterExport} from "../protyle/export/util";+import {onWindowsMsg} from "../window/onWindowsMsg";/// #endifimport {Constants} from "../constants";import {appearance} from "../config/appearance";@@ -30,7 +31,6 @@ import {replaceLocalPath} from "../editor/rename";import {workspaceMenu} from "../menus/workspace";import {getWorkspaceName} from "./noRelyPCFunction";import {setTabPosition} from "../window/setHeader";-import {Tab} from "../layout/Tab";const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {if (key1 === "general") {@@ -356,18 +356,8 @@ export const initWindow = () => {winOnClose(currentWindow, close);});}- ipcRenderer.on(Constants.SIYUAN_CLOSETAB, (e, ipcData) => {- const tab = getInstanceById(ipcData);- if (tab && tab instanceof Tab) {- tab.parent.removeTab(ipcData);- }- });- ipcRenderer.on(Constants.SIYUAN_LOCK_SCREEN, () => {- exportLayout(false, () => {- fetchPost("/api/system/logoutAuth", {}, () => {- window.location.reload();- });- });+ ipcRenderer.on(Constants.SIYUAN_SEND_WINDOWS, (e, ipcData: IWebSocketData) => {+ onWindowsMsg(ipcData);});ipcRenderer.on(Constants.SIYUAN_EXPORT_CLOSE, () => {window.siyuan.printWin.destroy();diff --git a/app/stage/auth.html b/app/stage/auth.htmlindex 2adb686519..82f16c7e40 100644--- a/app/stage/auth.html+++ b/app/stage/auth.html@@ -505,7 +505,7 @@return response.json()}).then((response) => {if (0 === response.code) {- window.location.href = '/'+ window.location.href = window.location.search.replace('?url=', '')return}