You've already forked AstralRinth
forked from didirus/AstralRinth
Revert "Rewrite cosmetics and theme preferences (#1292)"
This reverts commit 8704d3acb3.
This commit is contained in:
27
apps/frontend/src/plugins/1.theme.js
Normal file
27
apps/frontend/src/plugins/1.theme.js
Normal file
@@ -0,0 +1,27 @@
|
||||
export default defineNuxtPlugin(async (nuxtApp) => {
|
||||
await useAuth();
|
||||
await useUser();
|
||||
const themeStore = useTheme();
|
||||
const cosmetics = useCosmetics();
|
||||
|
||||
nuxtApp.hook("app:mounted", () => {
|
||||
if (import.meta.client && themeStore.value.preference === "system") {
|
||||
const colorSchemeQueryList = window.matchMedia("(prefers-color-scheme: light)");
|
||||
|
||||
const setColorScheme = (e) => {
|
||||
if (themeStore.value.preference === "system") {
|
||||
if (e.matches) {
|
||||
updateTheme("light");
|
||||
} else {
|
||||
updateTheme(cosmetics.value.preferredDarkTheme ?? "dark");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setColorScheme(colorSchemeQueryList);
|
||||
colorSchemeQueryList.addEventListener("change", setColorScheme);
|
||||
}
|
||||
});
|
||||
|
||||
nuxtApp.provide("colorMode", themeStore.value);
|
||||
});
|
||||
Reference in New Issue
Block a user