index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  18. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  19. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  20. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  21. }
  22. */
  23. // 公共路由
  24. export const constantRoutes = [
  25. {
  26. path: '/redirect',
  27. component: Layout,
  28. hidden: true,
  29. children: [
  30. {
  31. path: '/redirect/:path(.*)',
  32. component: (resolve) => require(['@/views/redirect'], resolve)
  33. }
  34. ]
  35. },
  36. {
  37. path: '/login',
  38. component: (resolve) => require(['@/views/login'], resolve),
  39. hidden: true
  40. },
  41. {
  42. path: '/404',
  43. component: (resolve) => require(['@/views/error/404'], resolve),
  44. hidden: true
  45. },
  46. {
  47. path: '/401',
  48. component: (resolve) => require(['@/views/error/401'], resolve),
  49. hidden: true
  50. },
  51. {
  52. path: '',
  53. component: Layout,
  54. redirect: 'index',
  55. children: [
  56. {
  57. path: 'index',
  58. component: (resolve) => require(['@/views/index'], resolve),
  59. name: '首页',
  60. meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
  61. }
  62. ]
  63. },
  64. {
  65. path: '/user',
  66. component: Layout,
  67. hidden: true,
  68. redirect: 'noredirect',
  69. children: [
  70. {
  71. path: 'profile',
  72. component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
  73. name: 'Profile',
  74. meta: { title: '个人中心', icon: 'user' }
  75. }
  76. ]
  77. },
  78. {
  79. path: '/auth',
  80. component: Layout,
  81. hidden: true,
  82. children: [
  83. {
  84. path: 'role/:userId(\\d+)',
  85. component: (resolve) => require(['@/views/system/user/authRole'], resolve),
  86. name: 'AuthRole',
  87. meta: { title: '分配角色'}
  88. }
  89. ]
  90. },
  91. {
  92. path: '/auth',
  93. component: Layout,
  94. hidden: true,
  95. children: [
  96. {
  97. path: 'user/:roleId(\\d+)',
  98. component: (resolve) => require(['@/views/system/role/authUser'], resolve),
  99. name: 'AuthUser',
  100. meta: { title: '分配用户'}
  101. }
  102. ]
  103. },
  104. {
  105. path: '/dict',
  106. component: Layout,
  107. hidden: true,
  108. children: [
  109. {
  110. path: 'type/data/:dictId(\\d+)',
  111. component: (resolve) => require(['@/views/system/dict/data'], resolve),
  112. name: 'Data',
  113. meta: { title: '字典数据', icon: '' }
  114. }
  115. ]
  116. },
  117. {
  118. path: '/job',
  119. component: Layout,
  120. hidden: true,
  121. children: [
  122. {
  123. path: 'log',
  124. component: (resolve) => require(['@/views/monitor/job/log'], resolve),
  125. name: 'JobLog',
  126. meta: { title: '调度日志' }
  127. }
  128. ]
  129. },
  130. {
  131. path: '/gen',
  132. component: Layout,
  133. hidden: true,
  134. children: [
  135. {
  136. path: 'edit/:tableId(\\d+)',
  137. component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
  138. name: 'GenEdit',
  139. meta: { title: '修改生成配置' }
  140. }
  141. ]
  142. }
  143. ]
  144. export default new Router({
  145. mode: 'history', // 去掉url中的#
  146. scrollBehavior: () => ({ y: 0 }),
  147. routes: constantRoutes
  148. })