🚸 🐛 Fix HMR issues & change lang without reload

- Fix HMR issues due to circular import of "language" and "i18n"
- Move i18n to seperate file
- Dynamically update language instead of doing a full page reload
This commit is contained in:
2023-06-05 19:11:15 +02:00
parent d1910a7877
commit 7928e4941f
4 changed files with 26 additions and 18 deletions

View File

@ -1,7 +1,7 @@
import { ref, watch, computed } from "vue";
import router from "./router";
import i18n from "./main";
import { getNextAndPrevDay } from "./util";
import i18n from "./i18n";
/* Router */
export const lastRoute = ref();
@ -14,7 +14,7 @@ export const classFilter = ref(localStorage.getItem("classFilter") || "none");
export const timetableGroups = ref(
JSON.parse(localStorage.getItem("timetableGroups") || "[]")
);
export const language = ref(localStorage.getItem("lang") || "en");
export const theme = ref(localStorage.getItem("theme") || "auto");
watch(classFilter, (newValue) => {
@ -24,10 +24,6 @@ watch(classFilter, (newValue) => {
watch(timetableGroups, (newValue) => {
localStorage.setItem("timetableGroups", JSON.stringify(newValue));
});
watch(language, (newValue) => {
localStorage.setItem("lang", newValue);
location.reload();
});
watch(theme, (newValue) => {
localStorage.setItem("theme", newValue);
});