🐛 Fix circular import in router

This commit is contained in:
2023-06-05 19:45:48 +02:00
parent 7928e4941f
commit d3bfb379c4
3 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import { createRouter, createWebHistory } from "vue-router";
import { lastRoute } from "../store";
import { shouldLogin } from "../store";
import { ref, watch } from "vue";
import TimetableView from "../views/TimetableView.vue";
import SubstitutionView from "../views/SubstitutionView.vue";
import HistoryView from "../views/HistoryView.vue";
@ -47,9 +48,14 @@ const router = createRouter({
],
});
export let lastRoute = ref();
router.beforeEach((_to, from) => {
lastRoute.value = from;
return true;
});
watch(shouldLogin, (value) => {
if (value) router.push("/login");
});
export default router;