✨ Support subroutes of settings
This commit is contained in:
@ -2,14 +2,14 @@
|
|||||||
import { MenuIcon } from "lucide-vue-next";
|
import { MenuIcon } from "lucide-vue-next";
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { useRoute, useRouter, RouterLink } from "vue-router";
|
import { useRoute, useRouter, RouterLink } from "vue-router";
|
||||||
import { lastRoute } from "../router/index";
|
import { lastDataRoute } from "../router/index";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const routeName = computed(() => route.name);
|
const routeName = computed(() => route.name);
|
||||||
function goBack() {
|
function goBack() {
|
||||||
if (routeName.value != "title.settings") return;
|
if (!routeName.value.startsWith("title.settings")) return;
|
||||||
if (lastRoute.value.name) router.go(-1);
|
if (lastDataRoute.value.name) router.push(lastDataRoute.value.path);
|
||||||
else router.push("/timetable");
|
else router.push("/timetable");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -57,9 +57,11 @@ const router = createRouter({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export let lastRoute = ref();
|
export let lastDataRoute = ref();
|
||||||
router.beforeEach((_to, from) => {
|
router.beforeEach((_to, from) => {
|
||||||
lastRoute.value = from;
|
if (from.meta.dataView) {
|
||||||
|
lastDataRoute.value = from;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user