index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. // import menuNoShowData from './menu.js'
  4. Vue.use(Router)
  5. /* Layout */
  6. import Layout from '@/layout'
  7. /**
  8. * Note: sub-menu only appear when route children.length >= 1
  9. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  10. *
  11. * hidden: true if set true, item will not show in the sidebar(default is false)
  12. * alwaysShow: true if set true, will always show the root menu
  13. * if not set alwaysShow, when item has more than one children route,
  14. * it will becomes nested mode, otherwise not show the root menu
  15. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  16. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  17. * meta : {
  18. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  19. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  20. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  21. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  22. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  23. }
  24. */
  25. /**
  26. * constantRoutes
  27. * a base page that does not have permission requirements
  28. * all roles can be accessed
  29. */
  30. export const moreRoutes = [
  31. {
  32. path: '/base',
  33. component: Layout,
  34. redirect: '/base/dict',
  35. name: 'Base',
  36. alwaysShow: true,
  37. meta: { title: '基础数据', icon: 'dashboard' },
  38. children: [
  39. {
  40. path: 'dict',
  41. name: 'Dict',
  42. component: () => import('@/views/base/dict'),
  43. meta: { title: '系统字典' }
  44. },
  45. {
  46. path: 'dictDtl',
  47. name: 'DictDtl',
  48. hidden: true,
  49. component: () => import('@/views/base/dictDtl'),
  50. meta: { title: '系统字典详情' }
  51. }
  52. ]
  53. },
  54. {
  55. path: '/news',
  56. component: Layout,
  57. redirect: '/news/index',
  58. children: [{
  59. path: 'index',
  60. name: 'NewsIndex',
  61. component: () => import('@/views/news/index'),
  62. meta: { title: '洪楼News', icon: 'dashboard' }
  63. }]
  64. },
  65. {
  66. path: '/house',
  67. component: Layout,
  68. redirect: '/house/index',
  69. name: 'House',
  70. meta: { title: '楼盘管理', icon: 'dashboard' },
  71. children: [
  72. {
  73. path: 'index',
  74. name: 'HouseIndex',
  75. component: () => import('@/views/house/index'),
  76. meta: { title: '楼盘列表' }
  77. },
  78. {
  79. path: 'news',
  80. name: 'HouseNews',
  81. hidden: true,
  82. component: () => import('@/views/house/news'),
  83. meta: { title: '楼盘动态' }
  84. },
  85. {
  86. path: 'theme',
  87. name: 'HouseTheme',
  88. component: () => import('@/views/house/theme'),
  89. meta: { title: '模板主题' }
  90. },
  91. {
  92. path: 'comment',
  93. name: 'HouseComment',
  94. component: () => import('@/views/house/comment'),
  95. meta: { title: '楼盘评论' }
  96. },
  97. {
  98. path: 'old',
  99. name: 'HouseOld',
  100. component: () => import('@/views/house/old'),
  101. meta: { title: '房源管理' }
  102. },
  103. ]
  104. },
  105. {
  106. path: '/school',
  107. component: Layout,
  108. redirect: '/school/index',
  109. children: [{
  110. path: 'index',
  111. name: 'SchoolIndex',
  112. component: () => import('@/views/school/index'),
  113. meta: { title: '学校管理', icon: 'dashboard' }
  114. }]
  115. },
  116. {
  117. path: '/qa',
  118. component: Layout,
  119. redirect: '/qa/index',
  120. children: [{
  121. path: 'index',
  122. name: 'QaIndex',
  123. component: () => import('@/views/qa/index'),
  124. meta: { title: '问答管理', icon: 'dashboard' }
  125. }]
  126. },
  127. {
  128. path: '/tupai',
  129. component: Layout,
  130. redirect: '/tupai/index',
  131. children: [{
  132. path: 'index',
  133. name: 'TupaiIndex',
  134. component: () => import('@/views/tupai/index'),
  135. meta: { title: '土拍管理', icon: 'dashboard' }
  136. }]
  137. },
  138. {
  139. path: '/feedback',
  140. component: Layout,
  141. redirect: '/feedback/index',
  142. children: [{
  143. path: 'index',
  144. name: 'FeedbackIndex',
  145. component: () => import('@/views/feedback/index'),
  146. meta: { title: '反馈管理', icon: 'dashboard' }
  147. }]
  148. },
  149. {
  150. path: '/user',
  151. component: Layout,
  152. redirect: '/user/app',
  153. children: [{
  154. path: 'app',
  155. name: 'UserApp',
  156. component: () => import('@/views/user/app'),
  157. meta: { title: '用户管理', icon: 'dashboard', affix: true }
  158. }]
  159. },
  160. ]
  161. export const constantRoutes = [
  162. {
  163. path: '/login',
  164. component: () => import('@/views/login/index'),
  165. hidden: true
  166. },
  167. {
  168. path: '/404',
  169. component: () => import('@/views/404'),
  170. hidden: true
  171. },
  172. {
  173. path: '/',
  174. component: Layout,
  175. redirect: '/dashboard',
  176. children: [{
  177. path: 'dashboard',
  178. name: 'Dashboard',
  179. component: () => import('@/views/dashboard/index'),
  180. meta: { title: '首页', icon: 'dashboard' }
  181. }]
  182. },
  183. ...moreRoutes
  184. ]
  185. /**
  186. * asyncRoutes
  187. * the routes that need to be dynamically loaded based on user roles
  188. */
  189. export const asyncRoutes = [
  190. // {
  191. // path: '/example',
  192. // component: Layout,
  193. // redirect: '/example/table',
  194. // name: 'Example',
  195. // meta: { title: '测试', icon: 'dashboard' },
  196. // children: [
  197. // {
  198. // path: 'table',
  199. // name: 'Table',
  200. // component: () => import('@/views/table/index'),
  201. // meta: { title: 'Table' }
  202. // },
  203. // {
  204. // path: 'tree',
  205. // name: 'Tree',
  206. // component: () => import('@/views/tree/index'),
  207. // meta: { title: 'Tree' }
  208. // }
  209. // ]
  210. // },
  211. // 404 page must be placed at the end !!!
  212. { path: '*', redirect: '/404', hidden: true }
  213. ]
  214. const createRouter = () => new Router({
  215. mode: 'history', // require service support
  216. scrollBehavior: () => ({ y: 0 }),
  217. routes: constantRoutes
  218. })
  219. const router = createRouter()
  220. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  221. export function resetRouter() {
  222. const newRouter = createRouter()
  223. router.matcher = newRouter.matcher // reset router
  224. }
  225. export default router