index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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: sub-menu only appear when route children.length >= 1
  8. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  9. *
  10. * hidden: true if set true, item will not show in the sidebar(default is false)
  11. * alwaysShow: true if set true, will always show the root menu
  12. * if not set alwaysShow, when item has more than one children route,
  13. * it will becomes nested mode, otherwise not show the root menu
  14. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  15. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  16. * meta : {
  17. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  18. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  19. icon: 'svg-name' the icon show in the sidebar
  20. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  21. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  22. }
  23. */
  24. /**
  25. * constantRoutes
  26. * a base page that does not have permission requirements
  27. * all roles can be accessed
  28. */
  29. export const constantRoutes = [
  30. {
  31. path: '/',
  32. redirect: '/banner',
  33. hidden: true
  34. },
  35. {
  36. path: '/login',
  37. component: () => import('@/views/login'),
  38. hidden: true
  39. },
  40. {
  41. path: '/404',
  42. component: () => import('@/views/404'),
  43. hidden: true
  44. },
  45. {
  46. path: '/banner',
  47. component: Layout,
  48. children: [
  49. {
  50. path: '',
  51. name: 'Banner',
  52. component: () => import('@/views/index/banner'),
  53. meta: { title: 'Banner图片', icon: 'banner' }
  54. }
  55. ]
  56. },
  57. {
  58. path: '/label',
  59. component: Layout,
  60. children: [
  61. {
  62. path: '',
  63. name: 'label',
  64. component: () => import('@/views/index/label'),
  65. meta: { title: '首页标签', icon: 'label' }
  66. }
  67. ]
  68. },
  69. {
  70. path: '/advantage',
  71. component: Layout,
  72. children: [
  73. {
  74. path: '',
  75. name: 'Advantage',
  76. component: () => import('@/views/article/advantage'),
  77. meta: { title: '公司优势', icon: 'advantage' }
  78. }
  79. ]
  80. },
  81. {
  82. path: '/cooperation',
  83. component: Layout,
  84. children: [
  85. {
  86. path: '',
  87. name: 'Cooperation',
  88. component: () => import('@/views/cooperation/client'),
  89. meta: { title: '合作伙伴', icon: 'partner' }
  90. }
  91. ]
  92. },
  93. {
  94. path: '/case',
  95. component: Layout,
  96. children: [
  97. {
  98. path: '',
  99. name: 'Case',
  100. component: () => import('@/views/article/case'),
  101. meta: { title: '成功案例', icon: 'case' }
  102. }
  103. ]
  104. },
  105. {
  106. path: '/detail/:id',
  107. component: Layout,
  108. hidden: true,
  109. children: [
  110. {
  111. path: '',
  112. name: 'Article',
  113. component: () => import('@/views/article/detail'),
  114. meta: { title: '查看案例', icon: 'form' }
  115. }
  116. ]
  117. },
  118. {
  119. path: '/article/:id',
  120. component: Layout,
  121. children: [
  122. {
  123. path: '',
  124. name: 'Article',
  125. hidden: true,
  126. component: () => import('@/views/article/tinymce'),
  127. meta: { title: '编辑案例', icon: 'form' }
  128. }
  129. ]
  130. },
  131. {
  132. path: '/product',
  133. component: Layout,
  134. children: [
  135. {
  136. path: '',
  137. name: 'product',
  138. component: () => import('@/views/product/product'),
  139. meta: { title: '公司产品', icon: 'product' }
  140. }
  141. ]
  142. },
  143. {
  144. path: '/vipProduct',
  145. component: Layout,
  146. children: [
  147. {
  148. path: '',
  149. name: 'vipProduct',
  150. component: () => import('@/views/vipproduct/vip'),
  151. meta: { title: '会员产品', icon: 'vip' }
  152. }
  153. ]
  154. },
  155. {
  156. path: '/comment',
  157. component: Layout,
  158. children: [
  159. {
  160. path: '',
  161. name: 'Comment',
  162. component: () => import('@/views/comment/comment'),
  163. meta: { title: '查看留言', icon: 'comment' }
  164. }
  165. ]
  166. },
  167. {
  168. path: '/application',
  169. component: Layout,
  170. children: [
  171. {
  172. path: '',
  173. name: 'Comment',
  174. component: () => import('@/views/application/application'),
  175. meta: { title: '查看申请', icon: 'application' }
  176. }
  177. ]
  178. },
  179. // 404 page must be placed at the end !!!
  180. { path: '*', redirect: '/404', hidden: true }
  181. ]
  182. const createRouter = () => new Router({
  183. // mode: 'history', // require service support
  184. scrollBehavior: () => ({ y: 0 }),
  185. routes: constantRoutes
  186. })
  187. const router = createRouter()
  188. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  189. export function resetRouter() {
  190. const newRouter = createRouter()
  191. router.matcher = newRouter.matcher // reset router
  192. }
  193. export default router