提交 | 用户 | 时间
|
a57dc2
|
1 |
import Vue from 'vue' |
W |
2 |
import Router from 'vue-router' |
|
3 |
|
|
4 |
Vue.use(Router) |
|
5 |
|
|
6 |
/* Layout */ |
|
7 |
import Layout from '@/layout' |
|
8 |
|
|
9 |
/** |
|
10 |
* Note: 路由配置项 |
|
11 |
* |
|
12 |
* hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1 |
|
13 |
* alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面 |
|
14 |
* // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面 |
|
15 |
* // 若你想不管路由下面的 children 声明的个数都显示你的根路由 |
|
16 |
* // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由 |
|
17 |
* redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击 |
|
18 |
* name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题 |
|
19 |
* query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数 |
|
20 |
* roles: ['admin', 'common'] // 访问路由的角色权限 |
|
21 |
* permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限 |
|
22 |
* meta : { |
|
23 |
noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false) |
|
24 |
title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字 |
|
25 |
icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg |
|
26 |
breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示 |
|
27 |
activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。 |
|
28 |
} |
|
29 |
*/ |
|
30 |
|
|
31 |
// 公共路由 |
|
32 |
export const constantRoutes = [ |
|
33 |
{ |
|
34 |
path: '/redirect', |
|
35 |
component: Layout, |
|
36 |
hidden: true, |
|
37 |
children: [ |
|
38 |
{ |
|
39 |
path: '/redirect/:path(.*)', |
|
40 |
component: () => import('@/views/redirect') |
|
41 |
} |
|
42 |
] |
|
43 |
}, |
|
44 |
{ |
|
45 |
path: '/login', |
|
46 |
component: () => import('@/views/login'), |
|
47 |
hidden: true |
|
48 |
}, |
|
49 |
{ |
|
50 |
path: '/register', |
|
51 |
component: () => import('@/views/register'), |
|
52 |
hidden: true |
|
53 |
}, |
|
54 |
{ |
|
55 |
path: '/404', |
|
56 |
component: () => import('@/views/error/404'), |
|
57 |
hidden: true |
|
58 |
}, |
|
59 |
{ |
|
60 |
path: '/401', |
|
61 |
component: () => import('@/views/error/401'), |
|
62 |
hidden: true |
|
63 |
}, |
|
64 |
{ |
|
65 |
path: '', |
|
66 |
component: Layout, |
|
67 |
redirect: 'index', |
|
68 |
children: [ |
|
69 |
{ |
|
70 |
path: 'index', |
|
71 |
component: () => import('@/views/index'), |
|
72 |
name: 'Index', |
|
73 |
meta: { title: '首页', icon: 'dashboard', affix: true } |
|
74 |
} |
|
75 |
] |
|
76 |
}, |
|
77 |
{ |
|
78 |
path: '/tool', |
|
79 |
component: Layout, |
|
80 |
hidden: true, |
|
81 |
children: [ |
|
82 |
{ |
|
83 |
path: 'build/index', |
|
84 |
component: () => import('@/views/tool/build/index'), |
|
85 |
name: 'FormBuild', |
|
86 |
meta: { title: '表单设计', icon: '' } |
|
87 |
} |
|
88 |
] |
|
89 |
}, |
|
90 |
{ |
|
91 |
path: '/user', |
|
92 |
component: Layout, |
|
93 |
hidden: true, |
|
94 |
redirect: 'noredirect', |
|
95 |
children: [ |
|
96 |
{ |
|
97 |
path: 'profile', |
|
98 |
component: () => import('@/views/system/user/profile/index'), |
|
99 |
name: 'Profile', |
|
100 |
meta: { title: '个人中心', icon: 'user' } |
|
101 |
} |
|
102 |
] |
|
103 |
} |
|
104 |
] |
|
105 |
|
|
106 |
// 动态路由,基于用户权限动态去加载 |
|
107 |
export const dynamicRoutes = [ |
|
108 |
{ |
|
109 |
path: '/system/user-auth', |
|
110 |
component: Layout, |
|
111 |
hidden: true, |
|
112 |
permissions: ['system:user:edit'], |
|
113 |
children: [ |
|
114 |
{ |
|
115 |
path: 'role/:userId(\\d+)', |
|
116 |
component: () => import('@/views/system/user/authRole'), |
|
117 |
name: 'AuthRole', |
|
118 |
meta: { title: '分配角色', activeMenu: '/system/user' } |
|
119 |
} |
|
120 |
] |
|
121 |
}, |
|
122 |
{ |
|
123 |
path: '/system/role-auth', |
|
124 |
component: Layout, |
|
125 |
hidden: true, |
|
126 |
permissions: ['system:role:edit'], |
|
127 |
children: [ |
|
128 |
{ |
|
129 |
path: 'user/:roleId(\\d+)', |
|
130 |
component: () => import('@/views/system/role/authUser'), |
|
131 |
name: 'AuthUser', |
|
132 |
meta: { title: '分配用户', activeMenu: '/system/role' } |
|
133 |
} |
|
134 |
] |
|
135 |
}, |
|
136 |
{ |
|
137 |
path: '/system/dict-data', |
|
138 |
component: Layout, |
|
139 |
hidden: true, |
|
140 |
permissions: ['system:dict:list'], |
|
141 |
children: [ |
|
142 |
{ |
44f5fa
|
143 |
path: 'index/:dictId([a-zA-Z0-9]+)', |
a57dc2
|
144 |
component: () => import('@/views/system/dict/data'), |
W |
145 |
name: 'Data', |
|
146 |
meta: { title: '字典数据', activeMenu: '/system/dict' } |
|
147 |
} |
|
148 |
] |
|
149 |
}, |
|
150 |
{ |
|
151 |
path: '/system/oss-config', |
|
152 |
component: Layout, |
|
153 |
hidden: true, |
|
154 |
permissions: ['system:oss:list'], |
|
155 |
children: [ |
|
156 |
{ |
|
157 |
path: 'index', |
|
158 |
component: () => import('@/views/system/oss/config'), |
|
159 |
name: 'OssConfig', |
|
160 |
meta: { title: '配置管理', activeMenu: '/system/oss' } |
|
161 |
} |
|
162 |
] |
|
163 |
}, |
|
164 |
{ |
|
165 |
path: '/tool/gen-edit', |
|
166 |
component: Layout, |
|
167 |
hidden: true, |
|
168 |
permissions: ['tool:gen:edit'], |
|
169 |
children: [ |
|
170 |
{ |
|
171 |
path: 'index/:tableId(\\d+)', |
|
172 |
component: () => import('@/views/tool/gen/editTable'), |
|
173 |
name: 'GenEdit', |
|
174 |
meta: { title: '修改生成配置', activeMenu: '/tool/gen' } |
|
175 |
} |
|
176 |
] |
|
177 |
}, |
|
178 |
{ |
|
179 |
path: '/workflow/process', |
|
180 |
component: Layout, |
|
181 |
hidden: true, |
|
182 |
permissions: ['workflow:process:query'], |
|
183 |
children: [ |
|
184 |
{ |
|
185 |
path: 'start/:deployId([\\w|\\-]+)', |
|
186 |
component: () => import('@/views/workflow/work/start'), |
|
187 |
name: 'WorkStart', |
|
188 |
meta: { title: '发起流程', icon: '' } |
|
189 |
}, |
|
190 |
{ |
|
191 |
path: 'detail/:procInsId([\\w|\\-]+)', |
|
192 |
component: () => import('@/views/workflow/work/detail'), |
|
193 |
name: 'WorkDetail', |
|
194 |
meta: { title: '流程详情', activeMenu: '/work/own' } |
|
195 |
} |
|
196 |
] |
|
197 |
}, |
|
198 |
] |
|
199 |
|
|
200 |
// 防止连续点击多次路由报错 |
|
201 |
let routerPush = Router.prototype.push; |
|
202 |
let routerReplace = Router.prototype.replace; |
|
203 |
// push |
|
204 |
Router.prototype.push = function push(location) { |
|
205 |
return routerPush.call(this, location).catch(err => err) |
|
206 |
} |
|
207 |
// replace |
|
208 |
Router.prototype.replace = function push(location) { |
|
209 |
return routerReplace.call(this, location).catch(err => err) |
|
210 |
} |
|
211 |
|
|
212 |
export default new Router({ |
|
213 |
base: process.env.VUE_APP_CONTEXT_PATH, |
|
214 |
mode: 'history', // 去掉url中的# |
|
215 |
scrollBehavior: () => ({ y: 0 }), |
|
216 |
routes: constantRoutes |
|
217 |
}) |