mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
This commit is contained in:
parent
7f9be7fea2
commit
066bd25819
2 changed files with 20 additions and 14 deletions
|
|
@ -172,6 +172,19 @@ const winOnMaxRestore = async () => {
|
|||
/// #endif
|
||||
};
|
||||
|
||||
const saveUI = () => {
|
||||
exportLayout({
|
||||
reload: false,
|
||||
onlyData: false,
|
||||
errorExit: false
|
||||
});
|
||||
}
|
||||
|
||||
export const unbindSaveUI = () => {
|
||||
window.removeEventListener("beforeunload", saveUI);
|
||||
window.removeEventListener("pagehide", saveUI);
|
||||
}
|
||||
|
||||
export const initWindow = async (app: App) => {
|
||||
/// #if !BROWSER
|
||||
const winOnClose = (close = false) => {
|
||||
|
|
@ -509,19 +522,7 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%pa
|
|||
if (!isWindow()) {
|
||||
document.querySelector(".toolbar").classList.add("toolbar--browser");
|
||||
}
|
||||
window.addEventListener("beforeunload", () => {
|
||||
exportLayout({
|
||||
reload: false,
|
||||
onlyData: false,
|
||||
errorExit: false
|
||||
});
|
||||
}, false);
|
||||
window.addEventListener("pagehide", () => {
|
||||
exportLayout({
|
||||
reload: false,
|
||||
onlyData: false,
|
||||
errorExit: false
|
||||
});
|
||||
}, false);
|
||||
window.addEventListener("beforeunload", saveUI, false);
|
||||
window.addEventListener("pagehide", saveUI, false);
|
||||
/// #endif
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
|||
import {confirmDialog} from "../dialog/confirmDialog";
|
||||
import {App} from "../index";
|
||||
import {isBrowser} from "../util/functions";
|
||||
import {unbindSaveUI} from "../boot/onGetConfig";
|
||||
|
||||
const togglePinDock = (dock: Dock, icon: string) => {
|
||||
return {
|
||||
|
|
@ -276,6 +277,9 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
|||
});
|
||||
}
|
||||
}];
|
||||
if (window.siyuan.storage[Constants.LOCAL_LAYOUTS].length > 0) {
|
||||
layoutSubMenu.push({type: "separator"});
|
||||
}
|
||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].forEach((item: ISaveLayout) => {
|
||||
layoutSubMenu.push({
|
||||
iconHTML: Constants.ZWSP,
|
||||
|
|
@ -297,6 +301,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
|||
return;
|
||||
}
|
||||
fetchPost("/api/system/setUILayout", {layout: item.layout}, () => {
|
||||
unbindSaveUI();
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue