Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/17065

Vanessac089edf65f74
diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.ts
index efd9aa0c2d..68f60c3961 100644
--- a/app/src/boot/onGetConfig.ts
+++ b/app/src/boot/onGetConfig.ts
@@ -202,7 +202,7 @@ export const initWindow = async (app: App) => {
}
});
ipcRenderer.on(Constants.SIYUAN_SEND_WINDOWS, (e, ipcData: IWebSocketData) => {
- onWindowsMsg(ipcData);
+ onWindowsMsg(ipcData, app);
});
ipcRenderer.on(Constants.SIYUAN_HOTKEY, (e, data) => {
let matchCommand = false;
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index b1bde49dfa..9a5372aae1 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -233,14 +233,27 @@ export const setDefRefCount = (data: {
}
};
-export const lockScreen = (app: App) => {
+export const lockScreen = async (app: App) => {
if (window.siyuan.config.readonly) {
return;
}
app.plugins.forEach(item => {
item.eventBus.emit("lock-screen");
});
- fetchPost("/api/system/logoutAuth");
+ /// #if !MOBILE
+ exportLayout({
+ errorExit: false,
+ cb() {
+ fetchPost("/api/system/logoutAuth");
+ }
+ });
+ /// #else
+ if (window.siyuan.mobile.editor) {
+ await saveScroll(window.siyuan.mobile.editor.protyle);
+ fetchPost("/api/system/logoutAuth");
+ }
+ /// #endif
+
};
export const kernelError = () => {
diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.ts
index cc73bacb21..23a1de1a4d 100644
--- a/app/src/util/pathName.ts
+++ b/app/src/util/pathName.ts
@@ -65,25 +65,10 @@ export const getIdFromSYProtocol = (url: string) => {
/* redirect to auth page */
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/onWindowsMsg.ts b/app/src/window/onWindowsMsg.ts
index 950651470c..91870ff706 100644
--- a/app/src/window/onWindowsMsg.ts
+++ b/app/src/window/onWindowsMsg.ts
@@ -1,7 +1,8 @@
import {getInstanceById} from "../layout/util";
import {Tab} from "../layout/Tab";
-import {redirectToCheckAuth} from "../util/pathName";
import {isWindow} from "../util/functions";
+import {lockScreen} from "../dialog/processSystem";
+import {App} from "../index";
const closeTab = (ipcData: IWebSocketData) => {
const tab = getInstanceById(ipcData.data);
@@ -9,7 +10,7 @@ const closeTab = (ipcData: IWebSocketData) => {
tab.parent.removeTab(ipcData.data);
}
};
-export const onWindowsMsg = (ipcData: IWebSocketData) => {
+export const onWindowsMsg = (ipcData: IWebSocketData, app: App) => {
switch (ipcData.cmd) {
case "closetab":
closeTab(ipcData);
@@ -37,7 +38,7 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
break;
case "lockscreenByMode":
if (window.siyuan.config.system.lockScreenMode === 1) {
- redirectToCheckAuth();
+ lockScreen(app);
}
break;
}