index.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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'/'el-icon-x' 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: '/login',
  32. component: () => import('@/views/login/index'),
  33. hidden: true
  34. },
  35. {
  36. path: '/external/open_engin',
  37. name: 'open_engin',
  38. component: () => import('@/views/external/open_engin'),
  39. hidden: true
  40. },
  41. {
  42. path: '/404',
  43. component: () => import('@/views/404'),
  44. hidden: true
  45. },
  46. // {
  47. // path: '/',
  48. // component: Layout,
  49. // redirect: '/dashboard',
  50. // children: [{
  51. // path: 'dashboard',
  52. // name: 'Dashboard',
  53. // component: () => import('@/views/dashboard/index'),
  54. // meta: { title: '首页', icon: 'dashboard'}
  55. // }]
  56. // },
  57. // {
  58. // path: '/goods',
  59. // component: Layout,
  60. // name: 'goods',
  61. // meta: { title: '商品管理', icon: 'el-icon-s-help' },
  62. // children: [
  63. // {
  64. // path: 'goods_index',
  65. // name: 'goods_index',
  66. // component: () => import('@/views/goods/goods_index'),
  67. // meta: { title: '商品列表', icon: 'form' }
  68. // },
  69. // {
  70. // path: 'goods_add',
  71. // name: 'goods_add',
  72. // hidden: true,
  73. // component: () => import('@/views/goods/goods_add'),
  74. // meta: { title: '添加商品', icon: 'form', parent:{ name:'goods_index' }}
  75. // },
  76. // {
  77. // path: 'classify_index',
  78. // name: 'classify',
  79. // component: () => import('@/views/goods/classify_index'),
  80. // meta: { title: '分类管理', icon: 'form' }
  81. // }
  82. // ]
  83. // },
  84. // {
  85. // path: '/order',
  86. // component: Layout,
  87. // name: 'order',
  88. // meta: { title: '订单管理', icon: 'el-icon-s-help' },
  89. // children: [
  90. // {
  91. // path: 'order_list',
  92. // name: 'order_list',
  93. // component: () => import('@/views/order/order_list'),
  94. // meta: { title: '订单列表', icon: 'form'}
  95. // },
  96. // {
  97. // path: 'detail',
  98. // name: 'detail',
  99. // hidden: true,
  100. // component: () => import('@/views/order/detail'),
  101. // meta: { title: '订单详情', parent:{ name:'order_list' } },
  102. // },
  103. // {
  104. // path: 'order_refund',
  105. // name: 'order_refund',
  106. // component: () => import('@/views/order/order_refund'),
  107. // meta: { title: '维权订单', icon: 'form'},
  108. // },
  109. // {
  110. // path: 'order_refund/order_refund_detail',
  111. // name: 'order_refund_detail',
  112. // hidden: true,
  113. // component: () => import('@/views/order/order_refund_detail'),
  114. // meta: { title: '维权详情', parent:{ name:'order_refund' } }
  115. // },
  116. // {
  117. // path: 'invoice',
  118. // name: 'invoice',
  119. // component: () => import('@/views/order/invoice'),
  120. // meta: { title: '开发票', icon: 'form' }
  121. // }
  122. // ]
  123. // },
  124. // {
  125. // path: '/activity',
  126. // component: Layout,
  127. // name: 'activity',
  128. // meta: { title: '活动管理', icon: 'el-icon-s-help' },
  129. // children: [
  130. // {
  131. // path: 'seckill_index',
  132. // name: 'seckill_index',
  133. // component: () => import('@/views/activity/seckill_index'),
  134. // meta: { title: '秒杀活动', icon: 'form' }
  135. // },
  136. // {
  137. // path: 'seckill_add',
  138. // name: 'seckill_add',
  139. // hidden: true,
  140. // component: () => import('@/views/activity/seckill_add'),
  141. // meta: { title: '添加商品', icon: 'form', parent:{ name:'seckill_index' }}
  142. // },
  143. // {
  144. // path: 'coupon_index',
  145. // name: 'coupon',
  146. // component: () => import('@/views/activity/coupon_index'),
  147. // meta: { title: '优惠券设置', icon: 'form' }
  148. // }
  149. // ]
  150. // },
  151. // {
  152. // path: '/member',
  153. // component: Layout,
  154. // name: 'member',
  155. // meta: { title: '会员管理', icon: 'el-icon-s-help' },
  156. // children: [
  157. // {
  158. // path: 'index',
  159. // name: 'index',
  160. // component: () => import('@/views/member/index'),
  161. // meta: { title: '会员管理', icon: 'form' }
  162. // }
  163. // ]
  164. // },
  165. // {
  166. // path: '/settlement',
  167. // component: Layout,
  168. // name: 'settlement',
  169. // meta: { title: '结算管理', icon: 'el-icon-s-help' },
  170. // children: [
  171. // {
  172. // path: 'index',
  173. // name: 'settlement_index',
  174. // component: () => import('@/views/settlement/index'),
  175. // meta: { title: '结算管理', icon: 'form' }
  176. // }
  177. // ]
  178. // },
  179. // {
  180. // path: '/freight',
  181. // component: Layout,
  182. // name: 'freight',
  183. // meta: { title: '配送管理', icon: 'el-icon-s-help' },
  184. // children: [
  185. // {
  186. // path: 'index',
  187. // name: 'freight_index',
  188. // component: () => import('@/views/freight/index'),
  189. // meta: { title: '配送管理', icon: 'form' }
  190. // }
  191. // ]
  192. // },
  193. // {
  194. // path: '/storage',
  195. // component: Layout,
  196. // name: 'storage',
  197. // meta: { title: '仓储管理', icon: 'el-icon-s-help' },
  198. // children: [
  199. // {
  200. // path: 'index',
  201. // name: 'storage_index',
  202. // component: () => import('@/views/storage/index'),
  203. // meta: { title: '仓储管理', icon: 'form' }
  204. // }
  205. // ]
  206. // },
  207. // {
  208. // path: '/notice',
  209. // component: Layout,
  210. // name: 'notice',
  211. // meta: { title: '消息中心', icon: 'el-icon-s-help' },
  212. // children: [
  213. // {
  214. // path: 'index',
  215. // name: 'notice_index',
  216. // component: () => import('@/views/notice/index'),
  217. // meta: { title: '消息列表', icon: 'form' }
  218. // }
  219. // ]
  220. // },
  221. // {
  222. // path: '/setting',
  223. // component: Layout,
  224. // name: 'Setting',
  225. // meta: { title: '系统设置', icon: 'el-icon-s-tools' },
  226. // alwaysShow: true,
  227. // children: [
  228. // {
  229. // path: 'personal',
  230. // name: 'personal',
  231. // component: () => import('@/views/setting/personal'),
  232. // meta: { title: '个人信息', icon: 'table' }
  233. // },
  234. // {
  235. // path: 'account',
  236. // name: 'account',
  237. // component: () => import('@/views/setting/account'),
  238. // meta: { title: '账户管理', icon: 'table' }
  239. // },
  240. // {
  241. // path: 'role',
  242. // name: 'role',
  243. // component: () => import('@/views/setting/role'),
  244. // meta: { title: '权限管理', icon: 'table' }
  245. // },
  246. // {
  247. // path: 'oplog',
  248. // name: 'oplog',
  249. // component: () => import('@/views/setting/oplog'),
  250. // meta: { title: '操作日志', icon: 'table' }
  251. // },
  252. // {
  253. // path: 'banner',
  254. // name: 'banner',
  255. // component: () => import('@/views/setting/banner'),
  256. // meta: { title: '轮播图管理', icon: 'table' }
  257. // }
  258. // ]
  259. // },
  260. // 404 page must be placed at the end !!!
  261. // { path: '*', redirect: '/404', hidden: true }
  262. ]
  263. const createRouter = () => new Router({
  264. // mode: 'history', // require service support
  265. scrollBehavior: () => ({ y: 0 }),
  266. routes: constantRoutes
  267. })
  268. const router = createRouter()
  269. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  270. export function resetRouter() {
  271. const newRouter = createRouter()
  272. router.matcher = newRouter.matcher // reset router
  273. }
  274. export default router