mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
7a68c8ad1b
commit
f06a2e62a5
11 changed files with 175 additions and 71 deletions
|
|
@ -172,7 +172,11 @@ export const initWindow = () => {
|
||||||
focusByRange(getSelection().getRangeAt(0));
|
focusByRange(getSelection().getRangeAt(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exportLayout(false);
|
exportLayout({
|
||||||
|
reload: false,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false
|
||||||
|
});
|
||||||
window.siyuan.altIsPressed = false;
|
window.siyuan.altIsPressed = false;
|
||||||
window.siyuan.ctrlIsPressed = false;
|
window.siyuan.ctrlIsPressed = false;
|
||||||
window.siyuan.shiftIsPressed = false;
|
window.siyuan.shiftIsPressed = false;
|
||||||
|
|
@ -184,7 +188,9 @@ export const initWindow = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const winOnClose = (currentWindow: Electron.BrowserWindow, close = false) => {
|
const winOnClose = (currentWindow: Electron.BrowserWindow, close = false) => {
|
||||||
exportLayout(false, () => {
|
exportLayout({
|
||||||
|
reload: false,
|
||||||
|
cb() {
|
||||||
if (window.siyuan.config.appearance.closeButtonBehavior === 1 && !close) {
|
if (window.siyuan.config.appearance.closeButtonBehavior === 1 && !close) {
|
||||||
// 最小化
|
// 最小化
|
||||||
if ("windows" === window.siyuan.config.system.os) {
|
if ("windows" === window.siyuan.config.system.os) {
|
||||||
|
|
@ -203,7 +209,10 @@ export const initWindow = () => {
|
||||||
} else {
|
} else {
|
||||||
exitSiYuan();
|
exitSiYuan();
|
||||||
}
|
}
|
||||||
}, false, true);
|
},
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: true
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const winOnMaxRestore = () => {
|
const winOnMaxRestore = () => {
|
||||||
|
|
@ -469,10 +478,18 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%pa
|
||||||
document.querySelector(".toolbar").classList.add("toolbar--browser");
|
document.querySelector(".toolbar").classList.add("toolbar--browser");
|
||||||
}
|
}
|
||||||
window.addEventListener("beforeunload", () => {
|
window.addEventListener("beforeunload", () => {
|
||||||
exportLayout(false);
|
exportLayout({
|
||||||
|
reload: false,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false
|
||||||
|
});
|
||||||
}, false);
|
}, false);
|
||||||
window.addEventListener("pagehide", () => {
|
window.addEventListener("pagehide", () => {
|
||||||
exportLayout(false);
|
exportLayout({
|
||||||
|
reload: false,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false
|
||||||
|
});
|
||||||
}, false);
|
}, false);
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -323,23 +323,33 @@ export const about = {
|
||||||
const networkServeElement = about.element.querySelector("#networkServe") as HTMLInputElement;
|
const networkServeElement = about.element.querySelector("#networkServe") as HTMLInputElement;
|
||||||
networkServeElement.addEventListener("change", () => {
|
networkServeElement.addEventListener("change", () => {
|
||||||
fetchPost("/api/system/setNetworkServe", {networkServe: networkServeElement.checked}, () => {
|
fetchPost("/api/system/setNetworkServe", {networkServe: networkServeElement.checked}, () => {
|
||||||
exportLayout(false, () => {
|
exportLayout({
|
||||||
exitSiYuan();
|
reload: false,
|
||||||
}, false, true);
|
onlyData: false,
|
||||||
|
errorExit: true,
|
||||||
|
cb: exitSiYuan
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const googleAnalyticsElement = about.element.querySelector("#googleAnalytics") as HTMLInputElement;
|
const googleAnalyticsElement = about.element.querySelector("#googleAnalytics") as HTMLInputElement;
|
||||||
googleAnalyticsElement.addEventListener("change", () => {
|
googleAnalyticsElement.addEventListener("change", () => {
|
||||||
fetchPost("/api/system/setGoogleAnalytics", {googleAnalytics: googleAnalyticsElement.checked}, () => {
|
fetchPost("/api/system/setGoogleAnalytics", {googleAnalytics: googleAnalyticsElement.checked}, () => {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const uploadErrLogElement = about.element.querySelector("#uploadErrLog") as HTMLInputElement;
|
const uploadErrLogElement = about.element.querySelector("#uploadErrLog") as HTMLInputElement;
|
||||||
uploadErrLogElement.addEventListener("change", () => {
|
uploadErrLogElement.addEventListener("change", () => {
|
||||||
fetchPost("/api/system/setUploadErrLog", {uploadErrLog: uploadErrLogElement.checked}, () => {
|
fetchPost("/api/system/setUploadErrLog", {uploadErrLog: uploadErrLogElement.checked}, () => {
|
||||||
exportLayout(false, () => {
|
exportLayout({
|
||||||
exitSiYuan();
|
reload: false,
|
||||||
}, false, true);
|
onlyData: false,
|
||||||
|
errorExit: true,
|
||||||
|
cb: exitSiYuan
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const downloadInstallPkgElement = about.element.querySelector("#downloadInstallPkg") as HTMLInputElement;
|
const downloadInstallPkgElement = about.element.querySelector("#downloadInstallPkg") as HTMLInputElement;
|
||||||
|
|
|
||||||
|
|
@ -177,14 +177,22 @@ export const appearance = {
|
||||||
window.siyuan.config.appearance.themeLight !== response.data.themeLight ||
|
window.siyuan.config.appearance.themeLight !== response.data.themeLight ||
|
||||||
window.siyuan.config.appearance.themeDark !== response.data.themeDark
|
window.siyuan.config.appearance.themeDark !== response.data.themeDark
|
||||||
)) {
|
)) {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const OSTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
const OSTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||||
if (response.data.modeOS && (
|
if (response.data.modeOS && (
|
||||||
(response.data.mode === 1 && OSTheme === "light") || (response.data.mode === 0 && OSTheme === "dark")
|
(response.data.mode === 1 && OSTheme === "light") || (response.data.mode === 0 && OSTheme === "dark")
|
||||||
)) {
|
)) {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +223,11 @@ export const appearance = {
|
||||||
shell.openPath(path.join(window.siyuan.config.system.dataDir, "emojis"));
|
shell.openPath(path.join(window.siyuan.config.system.dataDir, "emojis"));
|
||||||
});
|
});
|
||||||
appearance.element.querySelector("#appearanceRefresh").addEventListener("click", () => {
|
appearance.element.querySelector("#appearanceRefresh").addEventListener("click", () => {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
appearance.element.querySelectorAll("select").forEach(item => {
|
appearance.element.querySelectorAll("select").forEach(item => {
|
||||||
|
|
@ -231,7 +243,11 @@ export const appearance = {
|
||||||
},
|
},
|
||||||
onSetappearance(data: IAppearance) {
|
onSetappearance(data: IAppearance) {
|
||||||
if (data.lang !== window.siyuan.config.appearance.lang || data.nativeEmoji !== window.siyuan.config.appearance.nativeEmoji) {
|
if (data.lang !== window.siyuan.config.appearance.lang || data.nativeEmoji !== window.siyuan.config.appearance.nativeEmoji) {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.siyuan.config.appearance = data;
|
window.siyuan.config.appearance = data;
|
||||||
|
|
|
||||||
|
|
@ -482,7 +482,11 @@ export const bazaar = {
|
||||||
mode: dataObj.themeMode === "dark" ? 1 : 0,
|
mode: dataObj.themeMode === "dark" ? 1 : 0,
|
||||||
}, response => {
|
}, response => {
|
||||||
if (window.siyuan.config.appearance.themeJS && bazaarType === "themes") {
|
if (window.siyuan.config.appearance.themeJS && bazaarType === "themes") {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bazaar._genMyHTML(bazaarType, app);
|
bazaar._genMyHTML(bazaarType, app);
|
||||||
|
|
@ -525,7 +529,11 @@ export const bazaar = {
|
||||||
(window.siyuan.config.appearance.mode === 1 && window.siyuan.config.appearance.themeDark === dataObj.name)
|
(window.siyuan.config.appearance.mode === 1 && window.siyuan.config.appearance.themeDark === dataObj.name)
|
||||||
)) {
|
)) {
|
||||||
if (window.siyuan.config.appearance.themeJS) {
|
if (window.siyuan.config.appearance.themeJS) {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const linkElement = (document.getElementById("themeDefaultStyle") as HTMLLinkElement);
|
const linkElement = (document.getElementById("themeDefaultStyle") as HTMLLinkElement);
|
||||||
linkElement.href = linkElement.href + "1";
|
linkElement.href = linkElement.href + "1";
|
||||||
|
|
@ -563,7 +571,11 @@ export const bazaar = {
|
||||||
bazaar._onBazaar(response, bazaarType, ["themes", "icons"].includes(bazaarType));
|
bazaar._onBazaar(response, bazaarType, ["themes", "icons"].includes(bazaarType));
|
||||||
// TODO destroy plugin
|
// TODO destroy plugin
|
||||||
if (bazaarType === "plugins") {
|
if (bazaarType === "plugins") {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -596,7 +608,11 @@ export const bazaar = {
|
||||||
(mode === 1 && window.siyuan.config.appearance.themeDark !== packageName) ||
|
(mode === 1 && window.siyuan.config.appearance.themeDark !== packageName) ||
|
||||||
(mode === 0 && window.siyuan.config.appearance.themeLight !== packageName)) &&
|
(mode === 0 && window.siyuan.config.appearance.themeLight !== packageName)) &&
|
||||||
window.siyuan.config.appearance.themeJS) {
|
window.siyuan.config.appearance.themeJS) {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this._genMyHTML("themes", app);
|
this._genMyHTML("themes", app);
|
||||||
fetchPost("/api/bazaar/getBazaarTheme", {}, response => {
|
fetchPost("/api/bazaar/getBazaarTheme", {}, response => {
|
||||||
|
|
@ -628,7 +644,11 @@ export const bazaar = {
|
||||||
enabled: (target as HTMLInputElement).checked
|
enabled: (target as HTMLInputElement).checked
|
||||||
}, () => {
|
}, () => {
|
||||||
// TODO destroy plugin
|
// TODO destroy plugin
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,11 @@ export const keymap = {
|
||||||
},
|
},
|
||||||
bindEvent() {
|
bindEvent() {
|
||||||
keymap.element.querySelector("#keymapRefreshBtn").addEventListener("click", () => {
|
keymap.element.querySelector("#keymapRefreshBtn").addEventListener("click", () => {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
const searchElement = keymap.element.querySelector("#keymapInput") as HTMLInputElement;
|
const searchElement = keymap.element.querySelector("#keymapInput") as HTMLInputElement;
|
||||||
const searchKeymapElement = keymap.element.querySelector("#searchByKey") as HTMLInputElement;
|
const searchKeymapElement = keymap.element.querySelector("#searchByKey") as HTMLInputElement;
|
||||||
|
|
|
||||||
|
|
@ -245,9 +245,12 @@ export const transactionError = () => {
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
exitSiYuan();
|
exitSiYuan();
|
||||||
/// #else
|
/// #else
|
||||||
exportLayout(false, () => {
|
exportLayout({
|
||||||
exitSiYuan();
|
reload: false,
|
||||||
}, false, true);
|
onlyData: false,
|
||||||
|
errorExit: true,
|
||||||
|
cb: exitSiYuan
|
||||||
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
});
|
});
|
||||||
btnsElement[1].addEventListener("click", () => {
|
btnsElement[1].addEventListener("click", () => {
|
||||||
|
|
|
||||||
|
|
@ -187,20 +187,26 @@ export const resetLayout = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const exportLayout = (reload: boolean, cb?: () => void, onlyData = false, errorExit = false) => {
|
export const exportLayout = (options: {
|
||||||
|
reload: boolean,
|
||||||
|
cb?: () => void,
|
||||||
|
onlyData: boolean,
|
||||||
|
errorExit: boolean,
|
||||||
|
dropEditScroll?: boolean
|
||||||
|
}) => {
|
||||||
if (isWindow()) {
|
if (isWindow()) {
|
||||||
const layoutJSON: any = {
|
const layoutJSON: any = {
|
||||||
layout: {},
|
layout: {},
|
||||||
};
|
};
|
||||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout, !!options.dropEditScroll);
|
||||||
if (onlyData) {
|
if (options.onlyData) {
|
||||||
return layoutJSON;
|
return layoutJSON;
|
||||||
}
|
}
|
||||||
sessionStorage.setItem("layout", JSON.stringify(layoutJSON));
|
sessionStorage.setItem("layout", JSON.stringify(layoutJSON));
|
||||||
if (reload) {
|
if (options.reload) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} else if (cb) {
|
} else if (options.cb) {
|
||||||
cb();
|
options.cb();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -215,18 +221,18 @@ export const exportLayout = (reload: boolean, cb?: () => void, onlyData = false,
|
||||||
left: dockToJSON(window.siyuan.layout.leftDock),
|
left: dockToJSON(window.siyuan.layout.leftDock),
|
||||||
right: dockToJSON(window.siyuan.layout.rightDock),
|
right: dockToJSON(window.siyuan.layout.rightDock),
|
||||||
};
|
};
|
||||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout, !!options.dropEditScroll);
|
||||||
if (onlyData) {
|
if (options.onlyData) {
|
||||||
return layoutJSON;
|
return layoutJSON;
|
||||||
}
|
}
|
||||||
fetchPost("/api/system/setUILayout", {
|
fetchPost("/api/system/setUILayout", {
|
||||||
layout: layoutJSON,
|
layout: layoutJSON,
|
||||||
errorExit // 后台不接受该参数,用于请求发生错误时退出程序
|
errorExit: options.errorExit // 后台不接受该参数,用于请求发生错误时退出程序
|
||||||
}, () => {
|
}, () => {
|
||||||
if (reload) {
|
if (options.reload) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} else if (cb) {
|
} else if (options.cb) {
|
||||||
cb();
|
options.cb();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -404,7 +410,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any) => {
|
export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any, dropEditScroll = false) => {
|
||||||
if (layout instanceof Layout) {
|
if (layout instanceof Layout) {
|
||||||
json.direction = layout.direction;
|
json.direction = layout.direction;
|
||||||
if (layout.parent) {
|
if (layout.parent) {
|
||||||
|
|
@ -453,7 +459,9 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any) => {
|
||||||
json.mode = layout.editor.protyle.preview.element.classList.contains("fn__none") ? "wysiwyg" : "preview";
|
json.mode = layout.editor.protyle.preview.element.classList.contains("fn__none") ? "wysiwyg" : "preview";
|
||||||
json.action = layout.editor.protyle.block.showAll ? Constants.CB_GET_ALL : "";
|
json.action = layout.editor.protyle.block.showAll ? Constants.CB_GET_ALL : "";
|
||||||
json.instance = "Editor";
|
json.instance = "Editor";
|
||||||
|
if (!dropEditScroll) {
|
||||||
json.scrollAttr = saveScroll(layout.editor.protyle, true);
|
json.scrollAttr = saveScroll(layout.editor.protyle, true);
|
||||||
|
}
|
||||||
} else if (layout instanceof Asset) {
|
} else if (layout instanceof Asset) {
|
||||||
json.path = layout.path;
|
json.path = layout.path;
|
||||||
if (layout.pdfObject) {
|
if (layout.pdfObject) {
|
||||||
|
|
@ -517,13 +525,13 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any) => {
|
||||||
layout.children.forEach((item: Layout | Wnd | Tab) => {
|
layout.children.forEach((item: Layout | Wnd | Tab) => {
|
||||||
const itemJSON = {};
|
const itemJSON = {};
|
||||||
json.children.push(itemJSON);
|
json.children.push(itemJSON);
|
||||||
layoutToJSON(item, itemJSON);
|
layoutToJSON(item, itemJSON, dropEditScroll);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (layout instanceof Tab) {
|
} else if (layout instanceof Tab) {
|
||||||
if (layout.model) {
|
if (layout.model) {
|
||||||
json.children = {};
|
json.children = {};
|
||||||
layoutToJSON(layout.model, json.children);
|
layoutToJSON(layout.model, json.children, dropEditScroll);
|
||||||
} else if (layout.headElement) {
|
} else if (layout.headElement) {
|
||||||
// 当前页签没有激活时编辑器没有初始化
|
// 当前页签没有激活时编辑器没有初始化
|
||||||
json.children = JSON.parse(layout.headElement.getAttribute("data-initdata") || "{}");
|
json.children = JSON.parse(layout.headElement.getAttribute("data-initdata") || "{}");
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,11 @@ export const workspaceMenu = (app:App, rect: DOMRect) => {
|
||||||
if (item.name === value) {
|
if (item.name === value) {
|
||||||
saveDialog.destroy();
|
saveDialog.destroy();
|
||||||
confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => {
|
confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => {
|
||||||
item.layout = exportLayout(false, undefined, true);
|
item.layout = exportLayout({
|
||||||
|
reload: false,
|
||||||
|
onlyData: true,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -148,7 +152,11 @@ export const workspaceMenu = (app:App, rect: DOMRect) => {
|
||||||
}
|
}
|
||||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
||||||
name: value,
|
name: value,
|
||||||
layout: exportLayout(false, undefined, true)
|
layout: exportLayout({
|
||||||
|
reload: false,
|
||||||
|
onlyData: true,
|
||||||
|
errorExit: false,
|
||||||
|
})
|
||||||
});
|
});
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
saveDialog.destroy();
|
saveDialog.destroy();
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,11 @@ export const initAssets = () => {
|
||||||
}, response => {
|
}, response => {
|
||||||
if (window.siyuan.config.appearance.themeJS) {
|
if (window.siyuan.config.appearance.themeJS) {
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
/// #else
|
/// #else
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
@ -261,14 +265,22 @@ export const setMode = (modeElementValue: number) => {
|
||||||
window.siyuan.config.appearance.themeLight !== response.data.themeLight ||
|
window.siyuan.config.appearance.themeLight !== response.data.themeLight ||
|
||||||
window.siyuan.config.appearance.themeDark !== response.data.themeDark
|
window.siyuan.config.appearance.themeDark !== response.data.themeDark
|
||||||
)) {
|
)) {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const OSTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
const OSTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||||
if (response.data.modeOS && (
|
if (response.data.modeOS && (
|
||||||
(response.data.mode === 1 && OSTheme === "light") || (response.data.mode === 0 && OSTheme === "dark")
|
(response.data.mode === 1 && OSTheme === "light") || (response.data.mode === 0 && OSTheme === "dark")
|
||||||
)) {
|
)) {
|
||||||
exportLayout(true);
|
exportLayout({
|
||||||
|
reload: true,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,12 @@ export const processMessage = (response: IWebSocketData) => {
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
/// #else
|
/// #else
|
||||||
if (response.data?.dropCurrentLayout) {
|
exportLayout({
|
||||||
window.location.reload();
|
reload: true,
|
||||||
} else {
|
onlyData: false,
|
||||||
exportLayout(true);
|
errorExit: false,
|
||||||
}
|
dropEditScroll: response.data?.resetScroll,
|
||||||
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,16 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
|
||||||
closeTab(ipcData);
|
closeTab(ipcData);
|
||||||
break;
|
break;
|
||||||
case "lockscreen":
|
case "lockscreen":
|
||||||
exportLayout(false, () => {
|
exportLayout({
|
||||||
|
reload: false,
|
||||||
|
onlyData: false,
|
||||||
|
errorExit: false,
|
||||||
|
cb() {
|
||||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||||
redirectToCheckAuth();
|
redirectToCheckAuth();
|
||||||
});
|
});
|
||||||
}, false, false);
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue