2018-01-09 16:52:26 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Router from 'vue-router';
|
2019-01-21 14:08:22 +00:00
|
|
|
import PageNotFound from '@/views/PageNotFound.vue';
|
|
|
|
import Home from '@/views/Home.vue';
|
2019-02-22 13:55:47 +00:00
|
|
|
import { UserRouteName, userRoutes } from './user';
|
|
|
|
import { EventRouteName, eventRoutes } from '@/router/event';
|
2019-06-17 15:15:27 +00:00
|
|
|
import { ActorRouteName, actorRoutes, MyAccountRouteName } from '@/router/actor';
|
2019-04-01 09:49:54 +00:00
|
|
|
import { ErrorRouteName, errorRoutes } from '@/router/error';
|
|
|
|
import { authGuardIfNeeded } from '@/router/guards/auth-guard';
|
2019-04-03 15:29:03 +00:00
|
|
|
import Search from '@/views/Search.vue';
|
2018-01-09 16:52:26 +00:00
|
|
|
|
|
|
|
Vue.use(Router);
|
|
|
|
|
2019-02-22 13:55:47 +00:00
|
|
|
enum GlobalRouteName {
|
|
|
|
HOME = 'Home',
|
|
|
|
PAGE_NOT_FOUND = 'PageNotFound',
|
2019-04-03 15:29:03 +00:00
|
|
|
SEARCH = 'Search',
|
|
|
|
}
|
|
|
|
|
|
|
|
function scrollBehavior(to) {
|
|
|
|
if (to.hash) {
|
|
|
|
return {
|
|
|
|
selector: to.hash,
|
|
|
|
// , offset: { x: 0, y: 10 }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return { x: 0, y: 0 };
|
2019-02-22 13:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hack to merge enums
|
|
|
|
// tslint:disable:variable-name
|
|
|
|
export const RouteName = {
|
|
|
|
...GlobalRouteName,
|
|
|
|
...UserRouteName,
|
|
|
|
...EventRouteName,
|
|
|
|
...ActorRouteName,
|
2019-06-17 15:15:27 +00:00
|
|
|
...MyAccountRouteName,
|
2019-04-01 09:49:54 +00:00
|
|
|
...ErrorRouteName,
|
2019-02-22 13:55:47 +00:00
|
|
|
};
|
|
|
|
|
2018-01-09 16:52:26 +00:00
|
|
|
const router = new Router({
|
2019-04-03 15:29:03 +00:00
|
|
|
scrollBehavior,
|
2018-01-09 16:52:26 +00:00
|
|
|
mode: 'history',
|
|
|
|
base: '/',
|
|
|
|
routes: [
|
2019-01-29 10:02:32 +00:00
|
|
|
...userRoutes,
|
2019-02-22 13:55:47 +00:00
|
|
|
...eventRoutes,
|
|
|
|
...actorRoutes,
|
2019-04-01 09:49:54 +00:00
|
|
|
...errorRoutes,
|
2019-04-03 15:29:03 +00:00
|
|
|
{
|
|
|
|
path: '/search/:searchTerm/:searchType?',
|
|
|
|
name: RouteName.SEARCH,
|
|
|
|
component: Search,
|
|
|
|
props: true,
|
|
|
|
meta: { requiredAuth: false },
|
|
|
|
},
|
2018-01-09 16:52:26 +00:00
|
|
|
{
|
|
|
|
path: '/',
|
2019-02-22 13:55:47 +00:00
|
|
|
name: RouteName.HOME,
|
2018-01-09 16:52:26 +00:00
|
|
|
component: Home,
|
|
|
|
meta: { requiredAuth: false },
|
|
|
|
},
|
2019-02-22 13:55:47 +00:00
|
|
|
|
2018-07-04 12:29:17 +00:00
|
|
|
{
|
|
|
|
path: '*',
|
2019-02-22 13:55:47 +00:00
|
|
|
name: RouteName.PAGE_NOT_FOUND,
|
2018-01-09 16:52:26 +00:00
|
|
|
component: PageNotFound,
|
|
|
|
meta: { requiredAuth: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2019-04-01 09:49:54 +00:00
|
|
|
router.beforeEach(authGuardIfNeeded);
|
|
|
|
|
2018-01-09 16:52:26 +00:00
|
|
|
export default router;
|