提交 | 用户 | 时间
|
fd2207
|
1 |
import Vue from 'vue' |
懒 |
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: '/user', |
|
79 |
component: Layout, |
|
80 |
hidden: true, |
|
81 |
redirect: 'noredirect', |
|
82 |
children: [ |
|
83 |
{ |
|
84 |
path: 'profile', |
|
85 |
component: () => import('@/views/system/user/profile/index'), |
|
86 |
name: 'Profile', |
|
87 |
meta: { title: '个人中心', icon: 'user' } |
|
88 |
} |
|
89 |
] |
|
90 |
} |
|
91 |
] |
|
92 |
|
|
93 |
// 动态路由,基于用户权限动态去加载 |
|
94 |
export const dynamicRoutes = [ |
|
95 |
{ |
|
96 |
path: '/system/user-auth', |
|
97 |
component: Layout, |
|
98 |
hidden: true, |
|
99 |
permissions: ['system:user:edit'], |
|
100 |
children: [ |
|
101 |
{ |
|
102 |
path: 'role/:userId(\\d+)', |
|
103 |
component: () => import('@/views/system/user/authRole'), |
|
104 |
name: 'AuthRole', |
|
105 |
meta: { title: '分配角色', activeMenu: '/system/user' } |
|
106 |
} |
|
107 |
] |
|
108 |
}, |
|
109 |
{ |
|
110 |
path: '/system/role-auth', |
|
111 |
component: Layout, |
|
112 |
hidden: true, |
|
113 |
permissions: ['system:role:edit'], |
|
114 |
children: [ |
|
115 |
{ |
|
116 |
path: 'user/:roleId(\\d+)', |
|
117 |
component: () => import('@/views/system/role/authUser'), |
|
118 |
name: 'AuthUser', |
|
119 |
meta: { title: '分配用户', activeMenu: '/system/role' } |
|
120 |
} |
|
121 |
] |
|
122 |
}, |
|
123 |
{ |
|
124 |
path: '/system/dict-data', |
|
125 |
component: Layout, |
|
126 |
hidden: true, |
|
127 |
permissions: ['system:dict:list'], |
|
128 |
children: [ |
|
129 |
{ |
|
130 |
path: 'index/:dictId(\\d+)', |
|
131 |
component: () => import('@/views/system/dict/data'), |
|
132 |
name: 'Data', |
|
133 |
meta: { title: '字典数据', activeMenu: '/system/dict' } |
|
134 |
} |
|
135 |
] |
|
136 |
}, |
|
137 |
{ |
|
138 |
path: '/main/formula-data', |
|
139 |
component: Layout, |
|
140 |
hidden: true, |
|
141 |
permissions: ['bs:formulaChild:list'], |
|
142 |
children: [ |
|
143 |
{ |
207eac
|
144 |
path: 'index', |
fd2207
|
145 |
component: () => import('@/views/main/bs/formulaChild/index'), |
懒 |
146 |
name: 'Data', |
|
147 |
meta: { title: '配方详情', activeMenu: '/main/bs/formulaChild' } |
|
148 |
} |
|
149 |
] |
|
150 |
}, |
|
151 |
{ |
|
152 |
path: '/main/route-data', |
|
153 |
component: Layout, |
|
154 |
hidden: true, |
|
155 |
permissions: ['bs:technologyRouteChild:list'], |
|
156 |
children: [ |
|
157 |
{ |
|
158 |
path: 'index', |
|
159 |
component: () => import('@/views/main/bs/technologyRouteChild/index'), |
|
160 |
name: 'Data', |
|
161 |
meta: { title: '工艺流程详情', activeMenu: '/main/bs/technologyRouteChild' } |
|
162 |
} |
|
163 |
] |
|
164 |
}, |
|
165 |
{ |
|
166 |
path: '/main/bom-data', |
|
167 |
component: Layout, |
|
168 |
hidden: true, |
|
169 |
permissions: ['bs:ProductBomChild:list'], |
|
170 |
children: [ |
|
171 |
{ |
|
172 |
path: 'index', |
|
173 |
component: () => import('@/views/main/bs/ProductBomChild/index'), |
|
174 |
name: 'Data', |
|
175 |
meta: { title: 'BOM子件信息', activeMenu: '/main/bs/ProductBomChild' } |
|
176 |
} |
|
177 |
] |
|
178 |
}, |
|
179 |
{ |
|
180 |
path: '/monitor/job-log', |
|
181 |
component: Layout, |
|
182 |
hidden: true, |
|
183 |
permissions: ['monitor:job:list'], |
|
184 |
children: [ |
|
185 |
{ |
|
186 |
path: 'index/:jobId(\\d+)', |
|
187 |
component: () => import('@/views/monitor/job/log'), |
|
188 |
name: 'JobLog', |
|
189 |
meta: { title: '调度日志', activeMenu: '/monitor/job' } |
|
190 |
} |
|
191 |
] |
|
192 |
}, |
|
193 |
{ |
|
194 |
path: '/tool/gen-edit', |
|
195 |
component: Layout, |
|
196 |
hidden: true, |
|
197 |
permissions: ['tool:gen:edit'], |
|
198 |
children: [ |
|
199 |
{ |
|
200 |
path: 'index/:tableId(\\d+)', |
|
201 |
component: () => import('@/views/tool/gen/editTable'), |
|
202 |
name: 'GenEdit', |
|
203 |
meta: { title: '修改生成配置', activeMenu: '/tool/gen' } |
|
204 |
} |
|
205 |
] |
|
206 |
}, |
|
207 |
{ |
|
208 |
path: '/main/workReport-data', |
|
209 |
component: Layout, |
|
210 |
hidden: true, |
|
211 |
permissions: ['om:workReport:list'], |
|
212 |
children: [ |
|
213 |
{ |
|
214 |
path: 'index', |
|
215 |
component: () => import('@/views/main/om/workReport/index'), |
|
216 |
name: 'Data', |
|
217 |
meta: { title: '报工记录表', activeMenu: '/main/om/workReport' } |
|
218 |
} |
|
219 |
] |
|
220 |
}, |
5f7e70
|
221 |
{ |
懒 |
222 |
path: '/main/orderScheduling-data', |
|
223 |
component: Layout, |
|
224 |
hidden: true, |
|
225 |
permissions: ['bs:workReport:list'], |
|
226 |
children: [ |
|
227 |
{ |
|
228 |
path: 'index', |
|
229 |
component: () => import('@/views/main/bs/orderScheduling/index'), |
|
230 |
name: 'Data', |
|
231 |
meta: { title: '报工记录表', activeMenu: '/main/bs/orderScheduling' } |
|
232 |
} |
|
233 |
] |
|
234 |
}, |
fd2207
|
235 |
] |
懒 |
236 |
|
|
237 |
// 防止连续点击多次路由报错 |
|
238 |
let routerPush = Router.prototype.push; |
|
239 |
let routerReplace = Router.prototype.replace; |
|
240 |
// push |
|
241 |
Router.prototype.push = function push(location) { |
|
242 |
return routerPush.call(this, location).catch(err => err) |
|
243 |
} |
|
244 |
// replace |
|
245 |
Router.prototype.replace = function push(location) { |
|
246 |
return routerReplace.call(this, location).catch(err => err) |
|
247 |
} |
|
248 |
|
|
249 |
export default new Router({ |
|
250 |
mode: 'history', // 去掉url中的# |
|
251 |
scrollBehavior: () => ({ y: 0 }), |
|
252 |
routes: constantRoutes |
|
253 |
}) |