cygnal/src/router/index.js

53 lines
1.3 KiB
JavaScript

import Vue from 'vue';
import Router from 'vue-router';
import store from '@/store';
import About from '@/views/About.vue';
import Onboarding from '@/views/Onboarding.vue';
import Settings from '@/views/Settings.vue';
Vue.use(Router);
const Map = () => import('@/views/Map.vue');
export default new Router({
routes: [
{
path: '/about',
name: 'About',
component: About,
},
{
path: '/map=:zoom/:lat/:lng',
name: 'SharedMap',
component: Map,
},
{
path: '/map',
name: 'Map',
component: Map,
beforeEnter: (to, from, next) => {
if (to.name !== 'SharedMap') {
// Check that intro was seen except if we are in SharedMap view.
// This is required in order to ensure NoSleep works well.
if (!store.state.hasGoneThroughIntro) {
return next({ name: 'Onboarding', replace: true });
}
}
return next();
},
},
{
path: '/',
name: 'Onboarding',
component: Onboarding,
},
{
path: '/settings',
name: 'Settings',
component: Settings,
},
],
});