set map_mode on first load

This commit is contained in:
2023-05-17 16:24:10 +02:00
parent 9b2490228f
commit 68ae6a20f3
3 changed files with 16 additions and 4 deletions

View File

@@ -3,6 +3,9 @@ import HomeView from '@views/Home.vue'
// import StaticView from '@views/Static.vue'
// import ConcernementView from '@views/Concernement.vue'
import { ConcernementsStore } from '@/stores/concernements'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
@@ -33,4 +36,16 @@ const router = createRouter({
]
})
// set map_mode on first load
router.afterEach((to, from) => {
const concernement_store = ConcernementsStore();
console.log('router afterEach', from, to, concernement_store.map_mode);
if (!from.name) { // we are at first load
if (to.hash) {
console.log("we have a hash");
concernement_store.setMapMode(to.hash.replace('#', ''));
}
}
})
export default router