🚸 Make menu button toggle settings
This commit is contained in:
@ -1,17 +1,28 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import MenuIcon from "./icons/menu-icon.vue";
|
import MenuIcon from "./icons/menu-icon.vue";
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { useRoute, RouterLink } from "vue-router";
|
import { useRoute, useRouter, RouterLink } from "vue-router";
|
||||||
|
import { lastRoute } from "../store";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
const routeName = computed(() => route.name);
|
const routeName = computed(() => route.name);
|
||||||
|
function goBack() {
|
||||||
|
if (routeName.value != "Settings") return;
|
||||||
|
if (lastRoute.value.name) router.go(-1);
|
||||||
|
else router.push("/timetable");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="titlebar">
|
<div class="titlebar">
|
||||||
<span class="title">{{ routeName }}</span>
|
<span class="title">{{ routeName }}</span>
|
||||||
<div class="settings">
|
<div class="settings">
|
||||||
<RouterLink to="/settings" v-show="$route.name != 'Login'">
|
<RouterLink
|
||||||
|
to="/settings"
|
||||||
|
v-show="$route.name != 'Login'"
|
||||||
|
@click="goBack()"
|
||||||
|
>
|
||||||
<MenuIcon />
|
<MenuIcon />
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { createRouter, createWebHistory } from "vue-router";
|
import { createRouter, createWebHistory } from "vue-router";
|
||||||
|
import { lastRoute } from "../store";
|
||||||
import TimetableView from "../views/TimetableView.vue";
|
import TimetableView from "../views/TimetableView.vue";
|
||||||
import SubstitutionView from "../views/SubstitutionView.vue";
|
import SubstitutionView from "../views/SubstitutionView.vue";
|
||||||
import HistoryView from "../views/HistoryView.vue";
|
import HistoryView from "../views/HistoryView.vue";
|
||||||
@ -40,4 +41,9 @@ const router = createRouter({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.beforeEach((_to, from) => {
|
||||||
|
lastRoute.value = from;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
@ -2,6 +2,8 @@ import { computed } from "@vue/reactivity";
|
|||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
|
|
||||||
|
export const lastRoute = ref();
|
||||||
|
|
||||||
export const substitutionFilter = ref(
|
export const substitutionFilter = ref(
|
||||||
localStorage.getItem("substitutionFilter") || "all"
|
localStorage.getItem("substitutionFilter") || "all"
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user