2020-02-18 07:57:00 +00:00
|
|
|
import Vue from "vue";
|
|
|
|
import Router, { Route } from "vue-router";
|
|
|
|
import VueScrollTo from "vue-scrollto";
|
|
|
|
import { PositionResult } from "vue-router/types/router.d";
|
|
|
|
import PageNotFound from "../views/PageNotFound.vue";
|
|
|
|
import Home from "../views/Home.vue";
|
|
|
|
import { eventRoutes } from "./event";
|
|
|
|
import { actorRoutes } from "./actor";
|
|
|
|
import { errorRoutes } from "./error";
|
|
|
|
import { authGuardIfNeeded } from "./guards/auth-guard";
|
|
|
|
import Search from "../views/Search.vue";
|
|
|
|
import { settingsRoutes } from "./settings";
|
|
|
|
import { groupsRoutes } from "./groups";
|
|
|
|
import { conversationRoutes } from "./conversation";
|
|
|
|
import { userRoutes } from "./user";
|
|
|
|
import RouteName from "./name";
|
2018-01-09 16:52:26 +00:00
|
|
|
|
|
|
|
Vue.use(Router);
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
function scrollBehavior(
|
|
|
|
to: Route,
|
|
|
|
from: Route,
|
|
|
|
savedPosition: any
|
|
|
|
): PositionResult | undefined | null {
|
2019-04-03 15:29:03 +00:00
|
|
|
if (to.hash) {
|
2019-11-15 17:36:47 +00:00
|
|
|
VueScrollTo.scrollTo(to.hash, 700);
|
2019-04-03 15:29:03 +00:00
|
|
|
return {
|
|
|
|
selector: to.hash,
|
2019-11-15 17:36:47 +00:00
|
|
|
offset: { x: 0, y: 10 },
|
2019-04-03 15:29:03 +00:00
|
|
|
};
|
|
|
|
}
|
2019-11-15 17:36:47 +00:00
|
|
|
if (savedPosition) {
|
|
|
|
return savedPosition;
|
|
|
|
}
|
|
|
|
|
2019-04-03 15:29:03 +00:00
|
|
|
return { x: 0, y: 0 };
|
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,
|
2020-02-18 07:57:00 +00:00
|
|
|
mode: "history",
|
|
|
|
base: "/",
|
2018-01-09 16:52:26 +00:00
|
|
|
routes: [
|
2019-01-29 10:02:32 +00:00
|
|
|
...userRoutes,
|
2019-02-22 13:55:47 +00:00
|
|
|
...eventRoutes,
|
2020-03-12 13:29:21 +00:00
|
|
|
...settingsRoutes,
|
2020-02-18 07:57:00 +00:00
|
|
|
...actorRoutes,
|
|
|
|
...groupsRoutes,
|
|
|
|
...conversationRoutes,
|
2019-04-01 09:49:54 +00:00
|
|
|
...errorRoutes,
|
2019-04-03 15:29:03 +00:00
|
|
|
{
|
2020-02-18 07:57:00 +00:00
|
|
|
path: "/search/:searchTerm/:searchType?",
|
2019-04-03 15:29:03 +00:00
|
|
|
name: RouteName.SEARCH,
|
|
|
|
component: Search,
|
|
|
|
props: true,
|
|
|
|
meta: { requiredAuth: false },
|
|
|
|
},
|
2018-01-09 16:52:26 +00:00
|
|
|
{
|
2020-02-18 07:57:00 +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-10-07 14:48:13 +00:00
|
|
|
{
|
2020-02-18 07:57:00 +00:00
|
|
|
path: "/about",
|
2019-10-07 14:48:13 +00:00
|
|
|
name: RouteName.ABOUT,
|
2020-02-18 07:57:00 +00:00
|
|
|
component: () => import(/* webpackChunkName: "about" */ "@/views/About.vue"),
|
2019-10-07 14:48:13 +00:00
|
|
|
meta: { requiredAuth: false },
|
|
|
|
},
|
2019-12-20 12:04:34 +00:00
|
|
|
{
|
2020-02-18 07:57:00 +00:00
|
|
|
path: "/terms",
|
2019-12-20 12:04:34 +00:00
|
|
|
name: RouteName.TERMS,
|
2020-02-18 07:57:00 +00:00
|
|
|
component: () => import(/* webpackChunkName: "cookies" */ "@/views/Terms.vue"),
|
2019-12-20 12:04:34 +00:00
|
|
|
meta: { requiredAuth: false },
|
|
|
|
},
|
2020-06-15 09:01:49 +00:00
|
|
|
{
|
|
|
|
path: "/rules",
|
|
|
|
name: RouteName.RULES,
|
|
|
|
component: () => import(/* webpackChunkName: "cookies" */ "@/views/Rules.vue"),
|
|
|
|
meta: { requiredAuth: false },
|
|
|
|
},
|
2019-12-20 12:04:34 +00:00
|
|
|
{
|
2020-02-18 07:57:00 +00:00
|
|
|
path: "/interact",
|
2019-12-20 12:04:34 +00:00
|
|
|
name: RouteName.INTERACT,
|
2020-02-18 07:57:00 +00:00
|
|
|
component: () => import(/* webpackChunkName: "cookies" */ "@/views/Interact.vue"),
|
2019-12-20 12:04:34 +00:00
|
|
|
meta: { requiredAuth: false },
|
|
|
|
},
|
2018-07-04 12:29:17 +00:00
|
|
|
{
|
2020-02-18 07:57:00 +00:00
|
|
|
path: "/404",
|
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-10-13 11:56:24 +00:00
|
|
|
{
|
2020-02-18 07:57:00 +00:00
|
|
|
path: "*",
|
2019-10-13 11:56:24 +00:00
|
|
|
redirect: { name: RouteName.PAGE_NOT_FOUND },
|
|
|
|
},
|
2018-01-09 16:52:26 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2019-04-01 09:49:54 +00:00
|
|
|
router.beforeEach(authGuardIfNeeded);
|
|
|
|
|
2018-01-09 16:52:26 +00:00
|
|
|
export default router;
|