mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 10:01:00 +01:00
42 lines
910 B
TypeScript
42 lines
910 B
TypeScript
import { createVuetify } from "vuetify";
|
|
import { themes, dark, light, autoThemeKey } from "@/styles/themes";
|
|
import { isKeyof } from "@/types";
|
|
|
|
import "vuetify/styles";
|
|
import "@mdi/font/css/materialdesignicons.css";
|
|
|
|
const mediaMatch = window.matchMedia("(prefers-color-scheme: dark)");
|
|
|
|
function getTheme() {
|
|
const storedTheme = parseInt(localStorage.getItem("settings.theme") ?? "");
|
|
|
|
if (
|
|
!isNaN(storedTheme) &&
|
|
storedTheme !== autoThemeKey &&
|
|
isKeyof(storedTheme, themes)
|
|
) {
|
|
return themes[storedTheme];
|
|
}
|
|
|
|
return mediaMatch.matches ? "dark" : "light";
|
|
}
|
|
|
|
const instance = createVuetify({
|
|
icons: {
|
|
defaultSet: "mdi",
|
|
},
|
|
theme: {
|
|
defaultTheme: getTheme(),
|
|
themes: {
|
|
dark,
|
|
light,
|
|
},
|
|
},
|
|
});
|
|
|
|
mediaMatch.addEventListener("change", (event) => {
|
|
instance.theme.global.name.value = event.matches ? "dark" : "light";
|
|
});
|
|
|
|
export default instance;
|