cygnal/src/router/index.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-06-25 18:29:57 +02:00
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';
2018-06-25 18:29:57 +02:00
Vue.use(Router);
const Map = () => import('@/views/Map.vue');
2018-06-25 18:29:57 +02:00
export default new Router({
routes: [
{
path: '/about',
name: 'About',
component: About,
},
{
path: '/map=:zoom/:lat/:lng',
name: 'SharedMap',
component: Map,
},
2018-06-25 18:29:57 +02:00
{
path: '/map',
2018-06-25 18:29:57 +02:00
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();
},
2018-06-25 18:29:57 +02:00
},
{
path: '/',
name: 'Onboarding',
component: Onboarding,
},
2018-06-25 18:29:57 +02:00
{
path: '/settings',
name: 'Settings',
component: Settings,
2018-06-25 18:29:57 +02:00
},
],
});