Blame view

src/utils/routerList.js 18.3 KB
1de913cf   ren   sdf
1
  import Layout from '@/layout'
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
2
  import { getInfo } from '../store/modules/user.js'
b32564ca   周超   11
3
  import {GetMenueRole} from '@/api/role'
1de913cf   ren   sdf
4
  
b32564ca   周超   11
5
  export   function getRoutes(permissions) {
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
6
7
8
9
      let userInfo = {}
      if (localStorage.userinfo) {
          userInfo = JSON.parse(localStorage.userinfo)
      }
c33c1243   周超   拉取王哥最新的
10
      var permissions = userInfo.permissions || [];
b32564ca   周超   11
11
12
13
14
   
  // var roles = await GetMenueRole();
  //  roles = roles.data.map(o=>o.code);
   
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
15
      let constantRoutes1 = []
c33c1243   周超   拉取王哥最新的
16
      if (userInfo.UserId == 1 || 1 == 1) {
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
17
          constantRoutes1 = [{
876011a8   周超   给志哥
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
              path: '/login',
              component: () =>
                  import('@/views/login/index'),
              hidden: true
          },
  
          {
              path: '/404',
              component: () =>
                  import('@/views/404'),
              hidden: true
          },
  
          {
              path: '/answerDetail',
              name: '答题详情',
              component: () =>
                  import('@/views/AnswerResult/detail.vue'),
              hidden: true
          },
  
  
          {
b32564ca   周超   11
41
              code:'home',
876011a8   周超   给志哥
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
              path: '/',
              component: Layout,
              redirect: '/dashboard',
              children: [{
                  path: 'dashboard',
                  name: '首页',
                  component: () =>
                      import('@/views/dashboard/index'),
                  meta: {
                      title: '首页',
                      icon: 'dashboard'
                  }
              }, {
                  path: 'live',
                  name: '直播观看',
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
57
                  component: () =>
876011a8   周超   给志哥
58
59
60
61
62
                      import('@/views/live/index'),
                  meta: {
                      title: '直播',
                      icon: 'video'
                  },
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
63
                  hidden: true
876011a8   周超   给志哥
64
65
66
67
              }]
          },
  
          {
b32564ca   周超   11
68
              code:'example',
876011a8   周超   给志哥
69
70
71
72
73
74
              path: '/example',
              component: Layout,
              redirect: '/example/table',
              name: 'Example',
              meta: {
                  title: '题库管理',
c33c1243   周超   拉取王哥最新的
75
76
                  icon: 'el-icon-s-help',
                  permissions: ['admin']
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
77
              },
876011a8   周超   给志哥
78
              children: [{
b32564ca   周超   11
79
                  code:'题库',
876011a8   周超   给志哥
80
81
82
83
84
85
                  path: 'QuestionBank',
                  name: 'Table',
                  component: () =>
                      import('@/views/QuestionBank/index'),
                  meta: {
                      title: '题库',
c33c1243   周超   拉取王哥最新的
86
87
                      icon: 'table',
                      permissions: ['admin']
876011a8   周超   给志哥
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
                  }
              },]
          },
          // {
          //     path: '/moduleIndex',
          //     component: Layout,
          //     redirect: '/module/index',
          //     name: 'module',
          //     meta: {
          //         title: '面试题',
          //         icon: 'el-icon-s-help'
          //     },
          //     children: [{
          //         path: 'index',
          //         name: 'index',
          //         component: () =>
          //             import ('@/views/TestPaper/index'),
          //         hidden: true,
          //         meta: {
          //             title: '试卷维护',
          //             icon: 'table'
          //         }
          //     }, ]
          // },
          // {
          //     path: '/realQuestion',
          //     component: Layout,
          //     redirect: '/module/realQuestion',
          //     name: 'realQuestion',
          //     meta: {
          //         title: '历年真题',
          //         icon: 'el-icon-s-help'
          //     },
          //     children: [{
          //         path: 'recharge',
          //         name: 'recharge',
          //         component: () =>
          //             import ('@/views/module/realQuestion'),
          //         meta: {
          //             title: '历年真题',
          //             icon: 'el-icon-s-management'
          //         }
          //     }]
          // },
1de913cf   ren   sdf
132
  
876011a8   周超   给志哥
133
          {
b32564ca   周超   11
134
              code:'试卷管理',
876011a8   周超   给志哥
135
136
137
138
139
140
141
142
143
              path: '/views',
              component: Layout,
              redirect: '/views/TestPaper',
              name: 'TestPaper',
              meta: {
                  title: '试卷管理',
                  icon: 'el-icon-s-help'
              },
              children: [{
b32564ca   周超   11
144
                  code:'试卷列表',
876011a8   周超   给志哥
145
146
                  path: 'TestPaperList',
                  name: 'Table',
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
147
                  component: () =>
876011a8   周超   给志哥
148
149
150
151
152
                      import('@/views/TestPaper/TestPaperList'),
                  meta: {
                      title: '试卷列表',
                      icon: 'table'
                  }
1de913cf   ren   sdf
153
              },
1de913cf   ren   sdf
154
              {
876011a8   周超   给志哥
155
156
                  path: 'index',
                  name: 'index',
78156aa6   yangzhi   级联菜单
157
                  component: () =>
876011a8   周超   给志哥
158
159
160
161
162
163
                      import('@/views/TestPaper/index'),
                  hidden: true,
                  meta: {
                      title: '试卷维护',
                      icon: 'table'
                  }
78156aa6   yangzhi   级联菜单
164
              },
78156aa6   yangzhi   级联菜单
165
              {
b32564ca   周超   11
166
                  code:'组卷',
876011a8   周超   给志哥
167
168
169
170
171
172
173
174
                  path: 'ManualTestPaper',
                  name: 'Table',
                  component: () =>
                      import('@/views/TestPaper/ManualTestPaper'),
                  meta: {
                      title: '组卷',
                      icon: 'table'
                  }
1de913cf   ren   sdf
175
              },
1de913cf   ren   sdf
176
  
876011a8   周超   给志哥
177
178
              ]
          },
8ab6a817   周超   给王哥
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
          // {
          //     path: '/order',
          //     component: Layout,
          //     redirect: '/',
          //     name: 'order',
          //     meta: {
          //         title: '订单管理',
          //         icon: 'el-icon-s-marketing'
          //     },
          //     children: [{
          //         path: 'recharge',
          //         name: 'recharge',
          //         component: () =>
          //             import('@/views/order/rechargeList'),
          //         meta: {
          //             title: '充值记录',
          //         }
          //     }, {
          //         path: 'shop',
          //         name: 'shop',
          //         component: () =>
          //             import('@/views/order/shopList'),
          //         meta: {
          //             title: '购买记录',
          //         }
          //     }]
          // },
876011a8   周超   给志哥
206
          {
b32564ca   周超   11
207
              code:'用户管理',
876011a8   周超   给志哥
208
209
210
211
212
213
              path: '/user',
              component: Layout,
              redirect: '/',
              name: 'user',
              meta: {
                  title: '用户管理',
c33c1243   周超   拉取王哥最新的
214
                  icon: 'el-icon-s-help' 
ab275674   yangzhi   我在阳台抽烟 风抽一半我抽一半 我...
215
              },
876011a8   周超   给志哥
216
              children: [{
b32564ca   周超   11
217
                  code:'人才库',
876011a8   周超   给志哥
218
219
220
221
                  path: 'user',
                  name: 'User',
                  component: () =>
                      import('@/views/user/userlist'),
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
222
                  meta: {
876011a8   周超   给志哥
223
224
                      title: '人才库',
                  }
1de913cf   ren   sdf
225
226
              },
              {
b32564ca   周超   11
227
                  code:'面试时间表',
876011a8   周超   给志哥
228
229
230
231
                  path: 'interviewSchedule',
                  name: 'interviewSchedule',
                  component: () =>
                      import('@/views/user/InterviewSchedule'),
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
232
                  meta: {
876011a8   周超   给志哥
233
234
                      title: '面试时间表',
                  }
1de913cf   ren   sdf
235
              },
876011a8   周超   给志哥
236
  
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
237
              {
b32564ca   周超   11
238
                  code:'importuser',
876011a8   周超   给志哥
239
240
                  path: 'importuser',
                  name: 'importuser',
bde7e20f   周超   用户导入记录
241
  
876011a8   周超   给志哥
242
243
244
245
246
247
                  component: () =>
                      import('@/views/user/picuserimport'),
                  meta: {
                      title: '图片导入用户',
                  }
              },
876011a8   周超   给志哥
248
              {
b32564ca   周超   11
249
                  code: 'admin',
876011a8   周超   给志哥
250
251
                  path: 'admin',
                  name: 'admin',
876011a8   周超   给志哥
252
253
254
255
                  component: () =>
                      import('@/views/user/adminList'),
                  meta: {
                      title: '管理员列表',
c33c1243   周超   拉取王哥最新的
256
                      permissions: ['admin']
876011a8   周超   给志哥
257
258
                  }
              },
1de913cf   ren   sdf
259
  
876011a8   周超   给志哥
260
261
              ]
          }, {
b32564ca   周超   11
262
263
              code:'系统管理',
              path: '/system',
876011a8   周超   给志哥
264
265
266
267
268
269
270
              component: Layout,
              redirect: '/',
              name: 'password',
              meta: {
                  title: '系统管理',
                  icon: 'el-icon-s-platform'
              },
04aebc72   周超   11
271
272
              children: [
                  {
b32564ca   周超   11
273
                      code: 'userdimset',
04aebc72   周超   11
274
275
                      path: 'userdimset',
                      name: 'impouserdimsetrtuser',
c33c1243   周超   拉取王哥最新的
276
  
04aebc72   周超   11
277
278
279
280
                      component: () =>
                          import('@/views/user/userdimset'),
                      meta: {
                          title: '维度规则设置',
c33c1243   周超   拉取王哥最新的
281
                          permissions:['admin' ]
04aebc72   周超   11
282
283
284
                      }
                  },
                  {
c33c1243   周超   拉取王哥最新的
285
286
287
288
289
290
291
                      path: 'index',
                      name: 'index',
                      component: () =>
                          import('@/views/password/index'),
                      meta: {
                          title: '忘记密码',
                      }
b32564ca   周超   11
292
293
294
295
296
297
298
299
300
301
302
303
304
                  },
                  {
                      code:'settings',
                      path: 'settings',
                      name: 'settings',
                      component: () =>
                          import('@/views/settings/index'),
                      meta: {
                          title: '系统设置',
                      }
                  },
                  {
                      code:'TestPaperClass',
c33c1243   周超   拉取王哥最新的
305
306
307
308
309
310
311
312
313
                      path: 'TestPaperClass',
                      name: 'Table',
                      component: () =>
                          import('@/views/TestPaper/TestPaperClass'),
                      meta: {
                          title: '分类管理',
                          permissions:['admin' ]
                      }
                  }, {
b32564ca   周超   11
314
                      code: 'carousel',
c33c1243   周超   拉取王哥最新的
315
316
317
318
319
320
321
322
323
                      path: 'carousel',
                      name: 'carousel',
                      component: () =>
                          import('@/views/carousel/index'),
                      meta: {
                          title: '轮播图',
                          permissions:['admin' ]
                      }
                  }, {
b32564ca   周超   11
324
                      code: 'new',
c33c1243   周超   拉取王哥最新的
325
326
327
328
329
330
331
332
                      path: 'new',
                      name: 'new',
                      component: () =>
                          import('@/views/carousel/new'),
                      meta: {
                          title: '最新资讯',
                          permissions:['admin']
                      }
b32564ca   周超   11
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
                  }
                  , {
                      code: 'rolelist',
                      path: 'role',
                      name: 'rolelist',
                      component: () =>
                          import('@/views/user/rolelist'),
                      meta: {
                          title: '角色权限',
                          permissions:['admin']
                      }
                  },
                  {
                      code:'logs',
                      path: 'logs',
                      name: 'logs',
      
                      component: () =>
                          import('@/views/user/loglist'),
                      meta: {
                          title: '系统日志',
                      }
                  },
  
  
              ]
876011a8   周超   给志哥
359
360
361
362
363
364
365
          },
          // 404 page must be placed at the end !!!
          {
              path: '*',
              redirect: '/404',
              hidden: true
          }
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
366
367
          ]
      } else {
c33c1243   周超   拉取王哥最新的
368
          return ;
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
369
          constantRoutes1 = [{
876011a8   周超   给志哥
370
371
372
373
374
              path: '/login',
              component: () =>
                  import('@/views/login/index'),
              hidden: true
          },
1de913cf   ren   sdf
375
  
876011a8   周超   给志哥
376
377
378
379
380
381
382
383
384
385
386
387
388
389
          {
              path: '/404',
              component: () =>
                  import('@/views/404'),
              hidden: true
          },
  
          {
              path: '/example',
              component: Layout,
              redirect: '/example/table',
              name: 'Example',
              meta: {
                  title: '题库管理',
c33c1243   周超   拉取王哥最新的
390
391
                  icon: 'el-icon-s-help',
                  permissions: ["admin", "user"],
876011a8   周超   给志哥
392
393
394
395
              },
              children: [{
                  path: 'QuestionBank',
                  name: 'Table',
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
396
                  component: () =>
876011a8   周超   给志哥
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
                      import('@/views/QuestionBank/index'),
                  meta: {
                      title: '题库',
                      icon: 'table'
                  }
              },]
          },
          {
              path: '/moduleIndex',
              component: Layout,
              redirect: '/module/index',
              name: 'module',
              meta: {
                  title: '面试题',
                  icon: 'el-icon-s-help'
1de913cf   ren   sdf
412
              },
876011a8   周超   给志哥
413
414
415
416
417
              children: [{
                  path: 'recharge',
                  name: 'recharge',
                  component: () =>
                      import('@/views/module/index'),
ab275674   yangzhi   我在阳台抽烟 风抽一半我抽一半 我...
418
                  meta: {
876011a8   周超   给志哥
419
420
421
                      title: '面试题',
                      icon: 'el-icon-s-operation'
                  }
ab275674   yangzhi   我在阳台抽烟 风抽一半我抽一半 我...
422
              },
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
423
              {
876011a8   周超   给志哥
424
425
426
427
428
                  path: 'index',
                  name: 'index',
                  component: () =>
                      import('@/views/TestPaper/index'),
                  hidden: true,
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
429
                  meta: {
876011a8   周超   给志哥
430
431
432
                      title: '试卷维护',
                      icon: 'table'
                  }
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
433
              },
876011a8   周超   给志哥
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
              ]
          },
          // {
          //     path: '/realQuestion',
          //     component: Layout,
          //     redirect: '/module/realQuestion',
          //     name: 'realQuestion',
          //     meta: {
          //         title: '历年真题',
          //         icon: 'el-icon-s-help'
          //     },
          //     children: [{
          //         path: 'recharge',
          //         name: 'recharge',
          //         component: () =>
          //             import ('@/views/module/realQuestion'),
          //         meta: {
          //             title: '历年真题',
          //             icon: 'el-icon-s-management'
          //         }
          //     }]
          // },
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
456
  
876011a8   周超   给志哥
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
          {
              path: '/views',
              component: Layout,
              redirect: '/views/TestPaper',
              name: 'TestPaper',
              meta: {
                  title: '试卷管理',
                  icon: 'el-icon-s-help'
              },
              children: [{
                  path: 'TestPaperList',
                  name: 'Table',
                  component: () =>
                      import('@/views/TestPaper/TestPaperList'),
                  meta: {
                      title: '试卷列表',
                      icon: 'table'
                  }
              },
ab275674   yangzhi   我在阳台抽烟 风抽一半我抽一半 我...
476
              {
876011a8   周超   给志哥
477
478
479
480
481
                  path: 'index',
                  name: 'index',
                  component: () =>
                      import('@/views/TestPaper/index'),
                  hidden: true,
ab275674   yangzhi   我在阳台抽烟 风抽一半我抽一半 我...
482
                  meta: {
876011a8   周超   给志哥
483
484
485
486
487
488
489
490
491
492
493
494
495
                      title: '试卷维护',
                      icon: 'table'
                  }
              },
                  // {
                  //   path: 'ManualTestPaper',
                  //   name: 'Table',
                  //   component: () => import('@/views/TestPaper/ManualTestPaper'),
                  //   meta: {
                  //     title: '组卷',
                  //     icon: 'table'
                  //   }
                  // },
1de913cf   ren   sdf
496
  
876011a8   周超   给志哥
497
498
              ]
          },
8ab6a817   周超   给王哥
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
          // {
          //     path: '/order',
          //     component: Layout,
          //     redirect: '/',
          //     name: 'order',
          //     meta: {
          //         title: '订单管理',
          //         icon: 'el-icon-s-marketing'
          //     },
          //     children: [{
          //         path: 'recharge',
          //         name: 'recharge',
          //         component: () =>
          //             import('@/views/order/rechargeList'),
          //         meta: {
          //             title: '充值记录',
          //         }
          //     }, {
          //         path: 'shop',
          //         name: 'shop',
          //         component: () =>
          //             import('@/views/order/shopList'),
          //         meta: {
          //             title: '购买记录',
          //         }
          //     }]
          // },
876011a8   周超   给志哥
526
527
528
529
530
531
532
533
          {
              path: '/user',
              component: Layout,
              redirect: '/',
              name: 'user',
              meta: {
                  title: '用户管理',
                  icon: 'el-icon-s-help'
1de913cf   ren   sdf
534
              },
876011a8   周超   给志哥
535
536
537
538
539
              children: [{
                  path: 'user',
                  name: 'User',
                  component: () =>
                      import('@/views/user/userlist'),
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
540
                  meta: {
876011a8   周超   给志哥
541
542
                      title: '人才库',
                  }
c33c1243   周超   拉取王哥最新的
543
              }
1de913cf   ren   sdf
544
  
876011a8   周超   给志哥
545
546
547
548
549
550
551
552
              ]
          }, {
              path: '/password',
              component: Layout,
              redirect: '/',
              name: 'password',
              meta: {
                  title: '系统管理',
c33c1243   周超   拉取王哥最新的
553
554
                  icon: 'el-icon-s-platform',
                  permissions:['admin','user']
876011a8   周超   给志哥
555
556
557
558
559
560
561
562
563
              },
              children: [{
                  path: 'index',
                  name: 'index',
                  component: () =>
                      import('@/views/password/index'),
                  meta: {
                      title: '忘记密码',
                  }
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
564
              }, {
876011a8   周超   给志哥
565
566
567
568
                  path: 'TestPaperClass',
                  name: 'Table',
                  component: () =>
                      import('@/views/TestPaper/TestPaperClass'),
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
569
                  meta: {
876011a8   周超   给志哥
570
                      title: '分类管理',
c33c1243   周超   拉取王哥最新的
571
                      permissions: ['admin']
876011a8   周超   给志哥
572
573
574
575
576
577
578
579
                  }
              }, {
                  path: 'carousel',
                  name: 'carousel',
                  component: () =>
                      import('@/views/carousel/index'),
                  meta: {
                      title: '轮播图',
c33c1243   周超   拉取王哥最新的
580
                      permissions: ['admin']
876011a8   周超   给志哥
581
582
583
584
585
586
587
588
                  }
              }, {
                  path: 'new',
                  name: 'new',
                  component: () =>
                      import('@/views/carousel/new'),
                  meta: {
                      title: '最新资讯',
c33c1243   周超   拉取王哥最新的
589
                      permissions: ['admin']
876011a8   周超   给志哥
590
591
592
593
594
595
596
597
598
                  }
              }]
          },
          // 404 page must be placed at the end !!!
          {
              path: '*',
              redirect: '/404',
              hidden: true
          }
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
599
600
          ]
      }
1de913cf   ren   sdf
601
602
  
  
c33c1243   周超   拉取王哥最新的
603
604
605
606
607
608
609
610
611
612
613
614
615
      function hasPermission(permissions, route) {
          if (route.meta && route.meta.permissions) {
              return permissions.some((role) => route.meta.permissions.includes(role));
          } else {
              return true;
          }
      }
  
  
      function filterAsyncRoutes(routes, permissions) { 
          const finallyRoutes = [];
          routes.forEach((route) => {
              const item = { ...route };
b32564ca   周超   11
616
617
              // if (hasPermission(permissions, item)) {
                  if (permissions.includes(item.code) || !item.code) {
c33c1243   周超   拉取王哥最新的
618
619
620
621
622
623
624
625
626
                  if (item.children) {
                      item.children = filterAsyncRoutes(item.children, permissions);
                  }
                  finallyRoutes.push(item);
              }
          });
          return finallyRoutes;
      } 
      constantRoutes1 = filterAsyncRoutes(constantRoutes1, permissions);
b32564ca   周超   11
627
   
e0ca3a6e   yangzhi   大家快来看 王哥在看琅琊榜
628
629
      return constantRoutes1;
  }