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/17065
Vanessa448b04abf855
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.tsindex 016d6c6369..7d30e01efd 100644--- a/app/src/dialog/processSystem.ts+++ b/app/src/dialog/processSystem.ts@@ -240,13 +240,7 @@ export const lockScreen = (app: App) => {app.plugins.forEach(item => {item.eventBus.emit("lock-screen");});- /// #if BROWSER- fetchPost("/api/system/logoutAuth", {}, () => {- redirectToCheckAuth();- });- /// #else- ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "lockscreen"});- /// #endif+ fetchPost("/api/system/logoutAuth");};export const kernelError = () => {diff --git a/app/src/index.ts b/app/src/index.tsindex 3c6a1a9271..22d432c36f 100644--- a/app/src/index.ts+++ b/app/src/index.ts@@ -7,7 +7,7 @@ import {account} from "./config/account";import {addScript, addScriptSync} from "./protyle/util/addScript";import {genUUID} from "./util/genID";import {fetchGet, fetchPost} from "./util/fetch";-import {addBaseURL, getIdFromSYProtocol, isSYProtocol, setNoteBook} from "./util/pathName";+import {addBaseURL, getIdFromSYProtocol, isSYProtocol, redirectToCheckAuth, setNoteBook} from "./util/pathName";import {registerServiceWorker} from "./util/serviceWorker";import {openFileById} from "./editor/util";import {@@ -75,6 +75,9 @@ export class App {});if (data) {switch (data.cmd) {+ case "logoutAuth":+ redirectToCheckAuth();+ break;case "setAppearance":updateAppearance(data.data);break;diff --git a/app/src/mobile/util/onMessage.ts b/app/src/mobile/util/onMessage.tsindex b8d3a2ab10..28d3814b5e 100644--- a/app/src/mobile/util/onMessage.ts+++ b/app/src/mobile/util/onMessage.ts@@ -11,6 +11,7 @@ import {reloadEmoji} from "../../emoji";import {setLocalShorthandCount} from "../../util/noRelyPCFunction";import {updateControlAlt} from "../../protyle/util/hotKey";import {renderSnippet} from "../../config/util/snippets";+import {redirectToCheckAuth} from "../../util/pathName";let statusTimeout: number;const statusElement = document.querySelector("#status") as HTMLElement;@@ -18,6 +19,9 @@ const statusElement = document.querySelector("#status") as HTMLElement;export const onMessage = (app: App, data: IWebSocketData) => {if (data) {switch (data.cmd) {+ case "logoutAuth":+ redirectToCheckAuth();+ break;case "sendDeviceNotification":if (window.JSAndroid.sendNotification) {window.JSAndroid.sendNotification(data.data.title, data.data.body);diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.tsindex 12e9658b78..cc73bacb21 100644--- a/app/src/util/pathName.ts+++ b/app/src/util/pathName.ts@@ -9,11 +9,15 @@ import {Constants} from "../constants";/// #if !BROWSERimport {ipcRenderer} from "electron";/// #endif+/// #if !MOBILE+import {exportLayout} from "../layout/util";+/// #endifimport {showMessage} from "../dialog/message";import {isOnlyMeta, isWindows, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";import {matchHotKey} from "../protyle/util/hotKey";import {Menu} from "../plugin/Menu";import {hasClosestByClassName} from "../protyle/util/hasClosest";+import {saveScroll} from "../protyle/scroll/saveScroll";export const useShell = (cmd: "showItemInFolder" | "openPath", filePath: string) => {/// #if !BROWSER@@ -60,11 +64,26 @@ export const getIdFromSYProtocol = (url: string) => {};/* redirect to auth page */-export const redirectToCheckAuth = (to: string = window.location.href) => {+export const redirectToCheckAuth = async (to: string = window.location.href) => {+ /// #if !MOBILE+ exportLayout({+ errorExit: false,+ cb() {+ const url = new URL(window.location.origin);+ url.pathname = "/check-auth";+ url.searchParams.set("to", to);+ window.location.href = url.href;+ }+ });+ /// #else+ if (window.siyuan.mobile.editor) {+ await saveScroll(window.siyuan.mobile.editor.protyle);+ }const url = new URL(window.location.origin);url.pathname = "/check-auth";url.searchParams.set("to", to);window.location.href = url.href;+ /// #endif};export const addBaseURL = () => {diff --git a/app/src/window/index.ts b/app/src/window/index.tsindex 5716e267b9..c993142e0a 100644--- a/app/src/window/index.ts+++ b/app/src/window/index.ts@@ -6,7 +6,7 @@ import {initBlockPopover} from "../block/popover";import {addScript, addScriptSync} from "../protyle/util/addScript";import {genUUID} from "../util/genID";import {fetchGet, fetchPost} from "../util/fetch";-import {addBaseURL, setNoteBook} from "../util/pathName";+import {addBaseURL, redirectToCheckAuth, setNoteBook} from "../util/pathName";import {openFileById} from "../editor/util";import {processSync,@@ -58,6 +58,9 @@ class App {});if (data) {switch (data.cmd) {+ case "logoutAuth":+ redirectToCheckAuth();+ break;case "setAppearance":updateAppearance(data.data);break;diff --git a/app/src/window/onWindowsMsg.ts b/app/src/window/onWindowsMsg.tsindex 267dea0016..2e3d15188f 100644--- a/app/src/window/onWindowsMsg.ts+++ b/app/src/window/onWindowsMsg.ts@@ -36,26 +36,9 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {});}break;- case "lockscreen":- exportLayout({- errorExit: false,- cb() {- fetchPost("/api/system/logoutAuth", {}, () => {- redirectToCheckAuth();- });- }- });- break;case "lockscreenByMode":if (window.siyuan.config.system.lockScreenMode === 1) {- exportLayout({- errorExit: false,- cb() {- fetchPost("/api/system/logoutAuth", {}, () => {- redirectToCheckAuth();- });- }- });+ redirectToCheckAuth();}break;}