mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-26 08:54:07 +01:00
This commit is contained in:
parent
3cc93f2425
commit
22565b9006
12 changed files with 84 additions and 216 deletions
|
|
@ -6,9 +6,7 @@ import {getAllModels} from "../layout/getAll";
|
|||
import {exportLayout} from "../layout/util";
|
||||
/// #endif
|
||||
import {fetchPost} from "./fetch";
|
||||
import {appearance} from "../config/appearance";
|
||||
import {isInAndroid, isInHarmony, isInIOS, isIPad, isIPhone, isMac, isWin11} from "../protyle/util/compatibility";
|
||||
import {reloadOtherWindow} from "../dialog/processSystem";
|
||||
|
||||
export const loadAssets = (data: Config.IAppearance) => {
|
||||
const htmlElement = document.getElementsByTagName("html")[0];
|
||||
|
|
@ -357,42 +355,7 @@ export const setMode = (modeElementValue: number) => {
|
|||
fetchPost("/api/setting/setAppearance", Object.assign({}, window.siyuan.config.appearance, {
|
||||
mode,
|
||||
modeOS: modeElementValue === 2,
|
||||
}), async response => {
|
||||
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
||||
(response.data.mode === window.siyuan.config.appearance.mode && (
|
||||
(response.data.mode === 0 && window.siyuan.config.appearance.themeLight !== response.data.themeLight) ||
|
||||
(response.data.mode === 1 && window.siyuan.config.appearance.themeDark !== response.data.themeDark))
|
||||
)) {
|
||||
reloadOtherWindow();
|
||||
}
|
||||
if (window.siyuan.config.appearance.themeJS) {
|
||||
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
||||
(response.data.mode === window.siyuan.config.appearance.mode && (
|
||||
(response.data.mode === 0 && window.siyuan.config.appearance.themeLight !== response.data.themeLight) ||
|
||||
(response.data.mode === 1 && window.siyuan.config.appearance.themeDark !== response.data.themeDark))
|
||||
)
|
||||
) {
|
||||
if (window.destroyTheme) {
|
||||
try {
|
||||
await window.destroyTheme();
|
||||
window.destroyTheme = undefined;
|
||||
document.getElementById("themeScript").remove();
|
||||
} catch (e) {
|
||||
console.error("destroyTheme error: " + e);
|
||||
}
|
||||
} else {
|
||||
exportLayout({
|
||||
errorExit: false,
|
||||
cb() {
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
appearance.onSetAppearance(response.data);
|
||||
});
|
||||
}));
|
||||
/// #endif
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue