mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
44 lines
1019 B
TypeScript
44 lines
1019 B
TypeScript
import "@mdi/font/css/materialdesignicons.css";
|
|
import { useLocalStorage } from "@vueuse/core";
|
|
import { createVuetify } from "vuetify";
|
|
import { VDateInput } from "vuetify/labs/VDateInput";
|
|
import "vuetify/styles";
|
|
import { themes, dark, light, autoThemeKey } from "@/styles/themes";
|
|
import { isKeyof } from "@/types";
|
|
|
|
const mediaMatch = window.matchMedia("(prefers-color-scheme: dark)");
|
|
mediaMatch.addEventListener("change", (event) => {
|
|
instance.theme.change(event.matches ? "dark" : "light");
|
|
});
|
|
|
|
function getTheme() {
|
|
const storedTheme = useLocalStorage("settings.theme", autoThemeKey);
|
|
|
|
if (
|
|
storedTheme.value !== autoThemeKey &&
|
|
isKeyof(storedTheme.value, themes)
|
|
) {
|
|
return themes[storedTheme.value];
|
|
}
|
|
|
|
return mediaMatch.matches ? "dark" : "light";
|
|
}
|
|
|
|
const instance = createVuetify({
|
|
components: {
|
|
VDateInput,
|
|
},
|
|
icons: {
|
|
defaultSet: "mdi",
|
|
},
|
|
theme: {
|
|
defaultTheme: getTheme(),
|
|
themes: {
|
|
dark,
|
|
light,
|
|
},
|
|
},
|
|
});
|
|
|
|
export default instance;
|