fix: 🐛 刷新导致暗黑模式失效问题修复
Former-commit-id: 720471aaee612caf2aaea4969c381f3ba4108e9f
This commit is contained in:
@@ -81,7 +81,12 @@ onMounted(() => {
|
|||||||
window.document.body.setAttribute("layout", settingsStore.layout);
|
window.document.body.setAttribute("layout", settingsStore.layout);
|
||||||
const theme =
|
const theme =
|
||||||
localStorage.getItem("vueuse-color-scheme") || defaultSettings.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(
|
document.documentElement.style.setProperty(
|
||||||
"--el-color-primary",
|
"--el-color-primary",
|
||||||
settingsStore.themeColor
|
settingsStore.themeColor
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ export const useSettingsStore = defineStore("setting", () => {
|
|||||||
case "themeColor":
|
case "themeColor":
|
||||||
themeColor.value = value;
|
themeColor.value = value;
|
||||||
break;
|
break;
|
||||||
|
case "theme":
|
||||||
|
theme.value = value;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,5 +59,6 @@ export const useSettingsStore = defineStore("setting", () => {
|
|||||||
layout,
|
layout,
|
||||||
themeColor,
|
themeColor,
|
||||||
changeSetting,
|
changeSetting,
|
||||||
|
theme,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user