mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
47d137c40c
commit
92ddab06ea
5 changed files with 25 additions and 15 deletions
|
|
@ -21,11 +21,6 @@ import {isTouchDevice} from "../../util/functions";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
import {refreshFileTree} from "../../dialog/processSystem";
|
import {refreshFileTree} from "../../dialog/processSystem";
|
||||||
|
|
||||||
type filesPath = {
|
|
||||||
notebookId: string,
|
|
||||||
openPaths: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Files extends Model {
|
export class Files extends Model {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
public parent: Tab;
|
public parent: Tab;
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ const editLayout = (layoutName?: string) => {
|
||||||
layoutItem.name = value;
|
layoutItem.name = value;
|
||||||
layoutItem.time = new Date().getTime();
|
layoutItem.time = new Date().getTime();
|
||||||
layoutItem.layout = getAllLayout();
|
layoutItem.layout = getAllLayout();
|
||||||
|
layoutItem.filesPaths = window.siyuan.storage[Constants.LOCAL_FILESPATHS];
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +104,7 @@ const editLayout = (layoutName?: string) => {
|
||||||
confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => {
|
confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => {
|
||||||
item.layout = getAllLayout();
|
item.layout = getAllLayout();
|
||||||
item.time = new Date().getTime();
|
item.time = new Date().getTime();
|
||||||
|
item.filesPaths = window.siyuan.storage[Constants.LOCAL_FILESPATHS];
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -114,7 +116,8 @@ const editLayout = (layoutName?: string) => {
|
||||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
||||||
name: value,
|
name: value,
|
||||||
time: new Date().getTime(),
|
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]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
});
|
});
|
||||||
|
|
@ -344,8 +347,15 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} else {
|
} else {
|
||||||
fetchPost("/api/system/setUILayout", {layout: item.layout}, () => {
|
fetchPost("/api/system/setUILayout", {layout: item.layout}, () => {
|
||||||
|
if (item.filesPaths) {
|
||||||
|
window.siyuan.storage[Constants.LOCAL_FILESPATHS] = item.filesPaths;
|
||||||
|
setStorageVal(Constants.LOCAL_FILESPATHS, item.filesPaths, () => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,6 @@ import {App} from "../../index";
|
||||||
import {refreshFileTree} from "../../dialog/processSystem";
|
import {refreshFileTree} from "../../dialog/processSystem";
|
||||||
import {setStorageVal} from "../../protyle/util/compatibility";
|
import {setStorageVal} from "../../protyle/util/compatibility";
|
||||||
|
|
||||||
type filesPath = {
|
|
||||||
notebookId: string,
|
|
||||||
openPaths: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export class MobileFiles extends Model {
|
export class MobileFiles extends Model {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
private actionsElement: HTMLElement;
|
private actionsElement: HTMLElement;
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ export const getLocalStorage = (cb: () => void) => {
|
||||||
dark: "dark",
|
dark: "dark",
|
||||||
annoColor: "var(--b3-pdf-background1)"
|
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_AI] = []; // {name: "", memo: ""}
|
||||||
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
|
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
|
||||||
defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true};
|
defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true};
|
||||||
|
|
@ -231,7 +231,7 @@ export const getLocalStorage = (cb: () => void) => {
|
||||||
id: "",
|
id: "",
|
||||||
};
|
};
|
||||||
defaultStorage[Constants.LOCAL_FONTSTYLES] = [];
|
defaultStorage[Constants.LOCAL_FONTSTYLES] = [];
|
||||||
defaultStorage[Constants.LOCAL_FILESPATHS] = [];
|
defaultStorage[Constants.LOCAL_FILESPATHS] = []; // filesPath[]
|
||||||
defaultStorage[Constants.LOCAL_SEARCHDATA] = {
|
defaultStorage[Constants.LOCAL_SEARCHDATA] = {
|
||||||
page: 1,
|
page: 1,
|
||||||
sort: 0,
|
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) {
|
if (window.siyuan.config.readonly) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -301,5 +301,9 @@ export const setStorageVal = (key: string, val: any) => {
|
||||||
app: Constants.SIYUAN_APPID,
|
app: Constants.SIYUAN_APPID,
|
||||||
key,
|
key,
|
||||||
val,
|
val,
|
||||||
|
}, () => {
|
||||||
|
if (cb) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
6
app/src/types/index.d.ts
vendored
6
app/src/types/index.d.ts
vendored
|
|
@ -192,6 +192,11 @@ interface Window {
|
||||||
destroyTheme(): Promise<void>
|
destroyTheme(): Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface filesPath {
|
||||||
|
notebookId: string,
|
||||||
|
openPaths: string[]
|
||||||
|
}
|
||||||
|
|
||||||
interface IPosition {
|
interface IPosition {
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
|
|
@ -204,6 +209,7 @@ interface ISaveLayout {
|
||||||
name: string,
|
name: string,
|
||||||
layout: IObject
|
layout: IObject
|
||||||
time: number
|
time: number
|
||||||
|
filesPaths: filesPath[]
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IWorkspace {
|
interface IWorkspace {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue