forked from MCWXT/Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.js
More file actions
106 lines (105 loc) · 2.32 KB
/
Copy pathrouter.js
File metadata and controls
106 lines (105 loc) · 2.32 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { ref, reactive, watch } from 'vue';
import { createRouter, createWebHistory } from 'vue-router';
import { importComponent } from '/modules/index.js';
import Home from '/views/Home.js';
const routes = [
{
path: '/',
name: 'Home',
component: Home,
meta: {
title: '首页'
}
}, {
path: '/home',
redirect: '/'
}, {
path: '/error/:errorType',
name: 'Error',
component: importComponent('/views/Error'),
meta: {
title: '错误'
}
}, {
path: '/:pathMatch(.*)*',
redirect: '/error/404'
}, {
path: '/link',
name: 'Link',
component: importComponent('/views/Link'),
meta: {
title: '跳转链接'
}
}, {
path: '/link/to/:name',
name: 'LinkTo',
component: importComponent('/views/Link'),
meta: {
title: '跳转至…'
}
}, {
path: '/discussions',
name: 'Discussions',
component: importComponent('/views/discussion/Discussions'),
meta: {
title: '讨论'
}
}, {
path: '/discussions/:number',
name: 'Discussion',
component: importComponent('/views/Discussion/discussion'),
meta: {
title: '讨论'
}
}, {
path: '/mc/download',
name: 'DownloadMinecraft',
component: importComponent('/views/mc/Download'),
meta: {
title: '我的世界基岩版下载'
}
}, {
path: '/login',
name: 'Login',
component: importComponent('/views/login/Login'),
meta: {
title: '登录'
}
}, {
path: '/login/oauth',
name: 'Oauth',
component: importComponent('/views/login/Oauth'),
beforeEnter: (to) => to.query.state == 'MCWXT' && to.query.code && true || { path: '/error/400' },
meta: {
title: '授权'
}
}, /* {
path: '/bilibili',
children: [
{
path: '',
name: 'BiliBiliPopular',
component: importComponent('/views/bilibili/Popular'),
meta: {
title: 'B站热门'
}
}
]
}, */
]
const router = createRouter({
history: createWebHistory(),
routes,
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { top: 0 }
}
}
});
router.beforeEach((to, from, next) => {
document.title = to.meta.title ? 'MCWXT|' + to.meta.title : 'MCWXT的个人博客';
next()
});
export default router;