2018-06-25 18:29:57 +02:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Router from 'vue-router';
|
2018-08-05 15:47:28 +02:00
|
|
|
|
|
|
|
import store from '@/store';
|
|
|
|
|
2018-07-21 20:00:37 +02:00
|
|
|
import About from '@/views/About.vue';
|
2018-07-16 17:26:10 +02:00
|
|
|
import Onboarding from '@/views/Onboarding.vue';
|
2018-06-28 14:40:56 +02:00
|
|
|
import Settings from '@/views/Settings.vue';
|
2018-06-25 18:29:57 +02:00
|
|
|
|
|
|
|
Vue.use(Router);
|
|
|
|
|
2018-08-05 22:05:56 +02:00
|
|
|
const Map = () => import('@/views/Map.vue');
|
|
|
|
|
2018-06-25 18:29:57 +02:00
|
|
|
export default new Router({
|
|
|
|
routes: [
|
2018-06-28 14:40:56 +02:00
|
|
|
{
|
|
|
|
path: '/about',
|
|
|
|
name: 'About',
|
|
|
|
component: About,
|
|
|
|
},
|
2018-07-21 20:00:37 +02:00
|
|
|
{
|
|
|
|
path: '/map=:zoom/:lat/:lng',
|
|
|
|
name: 'SharedMap',
|
|
|
|
component: Map,
|
|
|
|
},
|
2018-06-25 18:29:57 +02:00
|
|
|
{
|
2018-07-16 17:26:10 +02:00
|
|
|
path: '/map',
|
2018-06-25 18:29:57 +02:00
|
|
|
name: 'Map',
|
|
|
|
component: Map,
|
2018-08-05 15:47:28 +02:00
|
|
|
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
|
|
|
},
|
2018-07-16 17:26:10 +02:00
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
name: 'Onboarding',
|
|
|
|
component: Onboarding,
|
|
|
|
},
|
2018-06-25 18:29:57 +02:00
|
|
|
{
|
2018-06-28 14:40:56 +02:00
|
|
|
path: '/settings',
|
|
|
|
name: 'Settings',
|
|
|
|
component: Settings,
|
2018-06-25 18:29:57 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|