mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
aa5f5ddc5f
commit
35853cfedb
5 changed files with 36 additions and 20 deletions
|
|
@ -451,12 +451,12 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%pa
|
||||||
/// #else
|
/// #else
|
||||||
if (!isWindow()) {
|
if (!isWindow()) {
|
||||||
document.querySelector(".toolbar").classList.add("toolbar--browser");
|
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
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,22 @@ export const resetLayout = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const exportLayout = (reload: boolean, cb?: () => void, onlyData = false, errorExit = false) => {
|
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");
|
const useElement = document.querySelector("#barDock use");
|
||||||
if (!useElement) {
|
if (!useElement) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,7 @@ export const processMessage = (response: IWebSocketData) => {
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
/// #else
|
/// #else
|
||||||
if (isWindow()) {
|
exportLayout(true);
|
||||||
window.location.reload();
|
|
||||||
} else {
|
|
||||||
exportLayout(true);
|
|
||||||
}
|
|
||||||
/// #endif
|
/// #endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,13 @@ export const init = () => {
|
||||||
globalShortcut();
|
globalShortcut();
|
||||||
fetchPost("/api/system/getEmojiConf", {}, response => {
|
fetchPost("/api/system/getEmojiConf", {}, response => {
|
||||||
window.siyuan.emojis = response.data as IEmoji[];
|
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"));
|
const tabJSON = JSON.parse(getSearch("json"));
|
||||||
tabJSON.active = true;
|
tabJSON.active = true;
|
||||||
JSONToCenter({
|
JSONToCenter({
|
||||||
|
|
@ -29,6 +36,7 @@ export const init = () => {
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
window.siyuan.layout.centerLayout = window.siyuan.layout.layout;
|
window.siyuan.layout.centerLayout = window.siyuan.layout.layout;
|
||||||
|
|
||||||
});
|
});
|
||||||
initStatus(true);
|
initStatus(true);
|
||||||
initWindow();
|
initWindow();
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,11 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
|
||||||
closeTab(ipcData);
|
closeTab(ipcData);
|
||||||
break;
|
break;
|
||||||
case "lockscreen":
|
case "lockscreen":
|
||||||
if (isWindow()) {
|
exportLayout(false, () => {
|
||||||
window.location.href = `/check-auth?url=${window.location.href}`;
|
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||||
} else {
|
window.location.href = `/check-auth?url=${window.location.href}`;
|
||||||
exportLayout(false, () => {
|
});
|
||||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
}, false, false);
|
||||||
window.location.href = `/check-auth?url=${window.location.href}`;
|
|
||||||
});
|
|
||||||
}, false, false);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue