-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (60 loc) · 1.36 KB
/
index.js
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
import Vue from 'vue';
import VueRouter from 'vue-router';
import PostList from '@_/theme/PostList.vue';
const PageNotFound = () =>
import(
/* webpackChunkName: "bundle.page-not-found" */ '@_/theme/page-not-found.vue'
);
Vue.use(VueRouter);
const parseId = router => {
let page = 0;
if (router.query.page) {
page = parseInt(router.query.page);
}
return {
id: router.params.id,
page
};
};
const routes = [
{
path: '/',
redirect: '/category/front-end'
},
{
path: '/login',
name: 'login',
component: () =>
import(/* webpackChunkName: "bundle.login" */ '@_/theme/Login.vue')
},
{
path: '/category/:id',
name: 'post-list',
props: parseId,
component: PostList
},
{
path: '*',
name: 'page-not-found',
component: PageNotFound
}
];
// const router = new VueRouter({
// mode: 'history',
// // linkExactActiveClass: 'is-active',
// linkActiveClass: 'is-active',
// scrollBehavior: (to, from, savedPosition) => ({ y: 0 }),
// // base: process.env.BASE_URL,
// routes
// });
// export default router;
const createRouter = () =>
new VueRouter({
mode: 'history',
// linkExactActiveClass: 'is-active',
linkActiveClass: 'is-active',
scrollBehavior: (to, from, savedPosition) => ({ y: 0 }),
// base: process.env.BASE_URL,
routes
});
export { createRouter };