routes.js
1.7 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
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-09 10:59:31
* @LastEditors: limin
* @LastEditTime: 2021-07-06 12:27:30
*/
const routesKeys = Object.freeze([
{
name: 'PermissionDennied',
path: 'home/dennied',
meta: {
title: '无访问权限',
isNoBack: true
}
},
{
name: 'Home',
path: 'home/index',
meta: {
title: '首页',
deepth: 1, // 标识路由的深度 数字越大深度越深 (用于判断路由的前进与返回)
keepAlive: false
}
},
{
name: 'Work',
path: 'work/index',
meta: {
title: '测试',
deepth: 1, // 标识路由的深度 数字越大深度越深 (用于判断路由的前进与返回)
keepAlive: false
}
},
{
name: 'Test',
path: 'work/sub/index',
meta: {
title: 'test',
deepth: 1, // 标识路由的深度 数字越大深度越深 (用于判断路由的前进与返回)
keepAlive: false
}
}
])
const keepAlives = []
const children = routesKeys.map(key => {
const { name, params, meta, path, redirect } = key
if (meta && meta.keepAlive) {
keepAlives.push(name)
}
let _path = `/${path.replace(/sub\/|\/index/g, '')}`
if (params) {
_path = `${_path}/:${params}`
}
console.log(_path)
return {
path: _path,
redirect,
name,
component: resolve => require([`views/${path}.vue`], resolve),
meta
}
})
const routes = [
{
path: '/',
component: resolve => require([`views/layouts/index`], resolve),
redirect: '/home',
meta: {
title: '首页',
keepAlive: false
},
children
}
]
routes.push({ path: '*', redirect: '/home' })
export const keeps = keepAlives
export default routes