Support subroutes of settings

This commit is contained in:
2023-06-06 19:35:02 +02:00
parent e416e599fa
commit 9164f56172
2 changed files with 7 additions and 5 deletions

View File

@ -2,14 +2,14 @@
import { MenuIcon } from "lucide-vue-next";
import { computed } from "vue";
import { useRoute, useRouter, RouterLink } from "vue-router";
import { lastRoute } from "../router/index";
import { lastDataRoute } from "../router/index";
const route = useRoute();
const router = useRouter();
const routeName = computed(() => route.name);
function goBack() {
if (routeName.value != "title.settings") return;
if (lastRoute.value.name) router.go(-1);
if (!routeName.value.startsWith("title.settings")) return;
if (lastDataRoute.value.name) router.push(lastDataRoute.value.path);
else router.push("/timetable");
}
</script>

View File

@ -57,9 +57,11 @@ const router = createRouter({
],
});
export let lastRoute = ref();
export let lastDataRoute = ref();
router.beforeEach((_to, from) => {
lastRoute.value = from;
if (from.meta.dataView) {
lastDataRoute.value = from;
}
return true;
});