diff --git a/src/router/index.js b/src/router/index.js index c71dfccacb5cd10621a9c4d413de62769a59a94e..4b4af3d2d76d8f7ad3b9b4aa7e18eab1017faafd 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,17 @@ import { createRouter, createWebHistory } from 'vue-router' import Start from '../views/Start.vue' +function guardMyroute(to, from, next) { + var hasMicrocosm = false + if (localStorage.getItem('nogg_microcosm')) hasMicrocosm = true + else hasMicrocosm = false + if (hasMicrocosm) { + next() // allow to enter route + } else { + next('/') // go to '/' + } +} + const routes = [ { path: '/', @@ -19,6 +30,7 @@ const routes = [ { path: '/collect', name: 'Collect', + beforeEnter: guardMyroute, // route level code-splitting // this generates a separate chunk (credits.[hash].js) for this route // which is lazy-loaded when the route is visited. @@ -29,6 +41,7 @@ const routes = [ { path: '/cards', name: 'Cards', + beforeEnter: guardMyroute, // route level code-splitting // this generates a separate chunk (credits.[hash].js) for this route // which is lazy-loaded when the route is visited.