index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /**
  7. * Note: 路由配置项
  8. *
  9. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  10. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  11. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  12. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  13. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  14. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  15. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  16. * meta : {
  17. roles: ['admin','editor'] // 设置该路由进入的权限,支持多个权限叠加
  18. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  19. icon: 'svg-name' // 设置该路由的图标,对应路径src/icons/svg
  20. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  21. }
  22. */
  23. // 公共路由
  24. export const constantRoutes = [
  25. {
  26. path: '/login',
  27. component: () => import('@/views/login'),
  28. hidden: true
  29. },
  30. {
  31. path: '/404',
  32. component: () => import('@/views/error/404'),
  33. hidden: true
  34. },
  35. {
  36. path: '/401',
  37. component: () => import('@/views/error/401'),
  38. hidden: true
  39. },
  40. {
  41. path: '',
  42. component: Layout,
  43. redirect: 'index',
  44. children: [
  45. {
  46. path: 'index',
  47. component: () => import('@/views/index'),
  48. name: '首页',
  49. meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
  50. }
  51. ]
  52. },
  53. {
  54. path: '/user',
  55. component: Layout,
  56. hidden: true,
  57. redirect: 'noredirect',
  58. children: [
  59. {
  60. path: 'profile',
  61. component: () => import('@/views/system/user/profile/index'),
  62. name: 'Profile',
  63. meta: { title: '个人中心', icon: 'user' }
  64. }
  65. ]
  66. },
  67. {
  68. path: '/dict',
  69. component: Layout,
  70. hidden: true,
  71. children: [
  72. {
  73. path: 'type/data/:dictId(\\d+)',
  74. component: () => import('@/views/system/dict/data'),
  75. name: 'Data',
  76. meta: { title: '字典数据', icon: '' }
  77. }
  78. ]
  79. },
  80. {
  81. path: '/gen',
  82. component: Layout,
  83. hidden: true,
  84. children: [
  85. {
  86. path: 'edit',
  87. component: () => import('@/views/tool/gen/editTable'),
  88. name: 'GenEdit',
  89. meta: { title: '修改生成配置' }
  90. }
  91. ]
  92. },
  93. { path: '*', redirect: '/404', hidden: true }
  94. ]
  95. export default new Router({
  96. mode: 'history', // 去掉url中的#
  97. scrollBehavior: () => ({ y: 0 }),
  98. routes: constantRoutes
  99. })