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/12485

Vanessa92ddab06ead8
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index 533743e82f..2e9b0be90d 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -21,11 +21,6 @@ import {isTouchDevice} from "../../util/functions";
import {App} from "../../index";
import {refreshFileTree} from "../../dialog/processSystem";
-type filesPath = {
- notebookId: string,
- openPaths: string[]
-}
-
export class Files extends Model {
public element: HTMLElement;
public parent: Tab;
diff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.ts
index f8e972d38b..c4657b5fdd 100644
--- a/app/src/menus/workspace.ts
+++ b/app/src/menus/workspace.ts
@@ -92,6 +92,7 @@ const editLayout = (layoutName?: string) => {
layoutItem.name = value;
layoutItem.time = new Date().getTime();
layoutItem.layout = getAllLayout();
+ layoutItem.filesPaths = window.siyuan.storage[Constants.LOCAL_FILESPATHS];
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
return true;
}
@@ -103,6 +104,7 @@ const editLayout = (layoutName?: string) => {
confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => {
item.layout = getAllLayout();
item.time = new Date().getTime();
+ item.filesPaths = window.siyuan.storage[Constants.LOCAL_FILESPATHS];
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
});
return true;
@@ -114,7 +116,8 @@ const editLayout = (layoutName?: string) => {
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
name: value,
time: new Date().getTime(),
- layout: getAllLayout()
+ layout: getAllLayout(),
+ filesPaths: window.siyuan.storage[Constants.LOCAL_FILESPATHS]
});
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
});
@@ -344,7 +347,14 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
window.location.reload();
} else {
fetchPost("/api/system/setUILayout", {layout: item.layout}, () => {
- window.location.reload();
+ if (item.filesPaths) {
+ window.siyuan.storage[Constants.LOCAL_FILESPATHS] = item.filesPaths;
+ setStorageVal(Constants.LOCAL_FILESPATHS, item.filesPaths, () => {
+ window.location.reload();
+ });
+ } else {
+ window.location.reload();
+ }
});
}
});
diff --git a/app/src/mobile/dock/MobileFiles.ts b/app/src/mobile/dock/MobileFiles.ts
index 1afc7c23a5..3408020cdf 100644
--- a/app/src/mobile/dock/MobileFiles.ts
+++ b/app/src/mobile/dock/MobileFiles.ts
@@ -17,11 +17,6 @@ import {App} from "../../index";
import {refreshFileTree} from "../../dialog/processSystem";
import {setStorageVal} from "../../protyle/util/compatibility";
-type filesPath = {
- notebookId: string,
- openPaths: string[]
-}
-
export class MobileFiles extends Model {
public element: HTMLElement;
private actionsElement: HTMLElement;
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index fcf3fe8560..49b1741a51 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -194,7 +194,7 @@ export const getLocalStorage = (cb: () => void) => {
dark: "dark",
annoColor: "var(--b3-pdf-background1)"
};
- defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}, time: number}
+ defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}, time: number, filespaths: filesPath[]}
defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true};
@@ -231,7 +231,7 @@ export const getLocalStorage = (cb: () => void) => {
id: "",
};
defaultStorage[Constants.LOCAL_FONTSTYLES] = [];
- defaultStorage[Constants.LOCAL_FILESPATHS] = [];
+ defaultStorage[Constants.LOCAL_FILESPATHS] = []; // filesPath[]
defaultStorage[Constants.LOCAL_SEARCHDATA] = {
page: 1,
sort: 0,
@@ -292,7 +292,7 @@ export const getLocalStorage = (cb: () => void) => {
});
};
-export const setStorageVal = (key: string, val: any) => {
+export const setStorageVal = (key: string, val: any, cb?:()=>void) => {
if (window.siyuan.config.readonly) {
return;
}
@@ -301,5 +301,9 @@ export const setStorageVal = (key: string, val: any) => {
app: Constants.SIYUAN_APPID,
key,
val,
+ }, () => {
+ if (cb) {
+ cb();
+ }
});
};
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index e191052698..9e78638d47 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -192,6 +192,11 @@ interface Window {
destroyTheme(): Promise<void>
}
+interface filesPath {
+ notebookId: string,
+ openPaths: string[]
+}
+
interface IPosition {
x: number,
y: number,
@@ -204,6 +209,7 @@ interface ISaveLayout {
name: string,
layout: IObject
time: number
+ filesPaths: filesPath[]
}
interface IWorkspace {