-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ts
74 lines (69 loc) · 1.61 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import Vue from "vue";
import VueRouter from "vue-router";
import Index from "@/views/IndexPage.vue";
import Directions from "@/views/DirectionsPage.vue";
import MySchedule from "@/views/MySchedule.vue";
import MyScheduleEdit from "@/views/MyScheduleEdit.vue";
import About from "@/views/AboutPage.vue";
import Feedback from "@/views/FeedbackPage.vue";
import Settings from "@/views/SettingsPage.vue";
Vue.use(VueRouter);
const routes = [
{ path: "/", component: Index },
{
path: "/directions",
component: Directions,
props: ({ query }: { query: { fromRoom?: string; toRoom?: string } }) => ({
fromRoom: query.fromRoom,
toRoom: query.toRoom,
}),
},
{
path: "/myschedule",
component: MySchedule,
},
{
path: "/myschedule/edit",
component: MyScheduleEdit,
},
{
path: "/about",
component: About,
},
{
path: "/feedback",
component: Feedback,
},
{
path: "/settings",
component: Settings,
},
{
path: "/graph",
component: () =>
import(/* webpackChunkName: 'graphpage' */ "@/views/GraphPage.vue"),
},
// fallback (client-side 404)
{
path: "*",
redirect: "/",
},
];
const router = new VueRouter({
routes,
mode: "history",
scrollBehavior(to, from, savedPosition) {
return { x: 0, y: 0 };
},
});
// Redirect hash URLs (old) to history mode URLs (new)
router.beforeEach((to, from, next) => {
// Redirect if fullPath begins with a hash (ignore hashes later in path)
if (to.fullPath.substr(0, 2) === "/#") {
const path = to.fullPath.substr(2);
next(path);
return;
}
next();
});
export default router;