Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/7913

Vanessa35853cfedb8c
diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.ts
index 21fcb6634c..82e3d35256 100644
--- a/app/src/boot/onGetConfig.ts
+++ b/app/src/boot/onGetConfig.ts
@@ -451,12 +451,12 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%pa
/// #else
if (!isWindow()) {
document.querySelector(".toolbar").classList.add("toolbar--browser");
- window.addEventListener("beforeunload", () => {
- exportLayout(false);
- }, false);
- window.addEventListener("pagehide", () => {
- exportLayout(false);
- }, false);
}
+ window.addEventListener("beforeunload", () => {
+ exportLayout(false);
+ }, false);
+ window.addEventListener("pagehide", () => {
+ exportLayout(false);
+ }, false);
/// #endif
};
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 4ec32d3347..c7b2d132d1 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -146,6 +146,22 @@ export const resetLayout = () => {
};
export const exportLayout = (reload: boolean, cb?: () => void, onlyData = false, errorExit = false) => {
+ if (isWindow()) {
+ const layoutJSON: any = {
+ layout: {},
+ };
+ layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
+ if (onlyData) {
+ return layoutJSON;
+ }
+ sessionStorage.setItem("layout", JSON.stringify(layoutJSON));
+ if (reload) {
+ window.location.reload();
+ } else if (cb) {
+ cb();
+ }
+ return ;
+ }
const useElement = document.querySelector("#barDock use");
if (!useElement) {
return;
diff --git a/app/src/util/processMessage.ts b/app/src/util/processMessage.ts
index 58652d66d8..ab4732a3a9 100644
--- a/app/src/util/processMessage.ts
+++ b/app/src/util/processMessage.ts
@@ -24,11 +24,7 @@ export const processMessage = (response: IWebSocketData) => {
/// #if MOBILE
window.location.reload();
/// #else
- if (isWindow()) {
- window.location.reload();
- } else {
- exportLayout(true);
- }
+ exportLayout(true);
/// #endif
return false;
}
diff --git a/app/src/window/init.ts b/app/src/window/init.ts
index 184f8a7faa..1506a6f382 100644
--- a/app/src/window/init.ts
+++ b/app/src/window/init.ts
@@ -15,6 +15,13 @@ export const init = () => {
globalShortcut();
fetchPost("/api/system/getEmojiConf", {}, response => {
window.siyuan.emojis = response.data as IEmoji[];
+
+ const layout = JSON.parse(sessionStorage.getItem("layout") || "{}");
+ if (layout.layout) {
+ JSONToCenter(layout.layout);
+ window.siyuan.layout.centerLayout = window.siyuan.layout.layout;
+ return;
+ }
const tabJSON = JSON.parse(getSearch("json"));
tabJSON.active = true;
JSONToCenter({
@@ -29,6 +36,7 @@ export const init = () => {
}]
});
window.siyuan.layout.centerLayout = window.siyuan.layout.layout;
+
});
initStatus(true);
initWindow();
diff --git a/app/src/window/onWindowsMsg.ts b/app/src/window/onWindowsMsg.ts
index b132f2f158..04b817eb5c 100644
--- a/app/src/window/onWindowsMsg.ts
+++ b/app/src/window/onWindowsMsg.ts
@@ -15,15 +15,11 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
closeTab(ipcData);
break;
case "lockscreen":
- if (isWindow()) {
- window.location.href = `/check-auth?url=${window.location.href}`;
- } else {
- exportLayout(false, () => {
- fetchPost("/api/system/logoutAuth", {}, () => {
- window.location.href = `/check-auth?url=${window.location.href}`;
- });
- }, false, false);
- }
+ exportLayout(false, () => {
+ fetchPost("/api/system/logoutAuth", {}, () => {
+ window.location.href = `/check-auth?url=${window.location.href}`;
+ });
+ }, false, false);
break;
}
};