fix: 🐛 刷新导致暗黑模式失效问题修复

This commit is contained in:
hxr 2023-11-02 23:34:41 +08:00
parent 7da2ea278b
commit 720471aaee
2 changed files with 10 additions and 1 deletions

View File

@ -81,7 +81,12 @@ onMounted(() => {
window.document.body.setAttribute("layout", settingsStore.layout);
const theme =
localStorage.getItem("vueuse-color-scheme") || defaultSettings.theme;
localStorage.setItem("vueuse-color-scheme", theme);
settingsStore.changeSetting({ key: "theme", value: theme });
if (theme != "light") {
document.documentElement.classList.add("dark");
}
document.documentElement.style.setProperty(
"--el-color-primary",
settingsStore.themeColor

View File

@ -45,6 +45,9 @@ export const useSettingsStore = defineStore("setting", () => {
case "themeColor":
themeColor.value = value;
break;
case "theme":
theme.value = value;
break;
}
}
@ -56,5 +59,6 @@ export const useSettingsStore = defineStore("setting", () => {
layout,
themeColor,
changeSetting,
theme,
};
});