mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 14:18:03 +00:00
feat: dark mode support (#53)
This commit is contained in:
parent
4e482941ed
commit
b655c59761
26 changed files with 301 additions and 181 deletions
|
|
@ -45,4 +45,24 @@ if ([undefined, null].includes(store.state.settings.lang)) {
|
|||
localStorage.setItem("settings", JSON.stringify(store.state.settings));
|
||||
}
|
||||
|
||||
if (
|
||||
store.state.settings.appearance !== "auto" &&
|
||||
store.state.settings.appearance !== undefined
|
||||
) {
|
||||
document.body.setAttribute("data-theme", store.state.settings.appearance);
|
||||
} else {
|
||||
document.body.setAttribute(
|
||||
"data-theme",
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
||||
);
|
||||
}
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
.addEventListener("change", (e) => {
|
||||
if (store.state.settings.appearance === "auto") {
|
||||
store.commit("updateTmpAppearance", e.matches ? "dark" : "light");
|
||||
document.body.setAttribute("data-theme", e.matches ? "dark" : "light");
|
||||
}
|
||||
});
|
||||
|
||||
export default store;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue