Skip to content
Snippets Groups Projects
Commit 40d69b9c authored by Adam Procter's avatar Adam Procter
Browse files

guarded routes when you have no microcosm

parent a976448d
No related branches found
No related tags found
No related merge requests found
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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment