✨ Support subroutes of settings
This commit is contained in:
@ -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>
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user