index.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. noCache: true if set true, the page will no be cached(default is false)
  21. affix: true if set true, the tag will affix in the tags-view
  22. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  23. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  24. }
  25. */
  26. /**
  27. * constantRoutes
  28. * a base page that does not have permission requirements
  29. * all roles can be accessed
  30. */
  31. export const constantRoutes = [
  32. {
  33. path: '/redirect',
  34. component: Layout,
  35. hidden: true,
  36. children: [
  37. {
  38. path: '/redirect/:path*',
  39. component: () => import('@/views/redirect/index')
  40. }
  41. ]
  42. },
  43. {
  44. path: '/login',
  45. component: () => import('@/views/login/index'),
  46. hidden: true
  47. },
  48. {
  49. path: '/auth-redirect',
  50. component: () => import('@/views/login/auth-redirect'),
  51. hidden: true
  52. },
  53. {
  54. path: '/404',
  55. component: () => import('@/views/error-page/404'),
  56. hidden: true
  57. },
  58. {
  59. path: '/401',
  60. component: () => import('@/views/error-page/401'),
  61. hidden: true
  62. },
  63. {
  64. path: '/',
  65. component: Layout,
  66. redirect: '/dashboard',
  67. children: [
  68. {
  69. path: 'dashboard',
  70. component: () => import('@/views/dashboard/index'),
  71. name: 'Dashboard',
  72. meta: { title: '首页', icon: 'dashboard', affix: true }
  73. }
  74. ]
  75. },
  76. {
  77. path: '/club',
  78. component: Layout,
  79. redirect: '/club/list',
  80. name: 'Club',
  81. meta: { title: '会所管理', icon: 'tree' },
  82. children: [
  83. {
  84. path: 'list',
  85. name: 'List',
  86. component: () => import('@/views/club/list'),
  87. meta: { title: '会所列表', icon: 'list' }
  88. },
  89. {
  90. path: 'form',
  91. name: 'Form',
  92. component: () => import('@/views/club/form'),
  93. meta: { title: '上线会所', icon: 'form' }
  94. },
  95. {
  96. path: 'operateList',
  97. component: () => import('@/views/club/operateList'),
  98. name: 'OperateList',
  99. meta: { title: '查看运营人员', noCache: true, activeMenu: '/club/list' },
  100. hidden: true
  101. },
  102. {
  103. path: 'editForm',
  104. component: () => import('@/views/club/editForm'),
  105. name: 'EditForm',
  106. meta: { title: '编辑会所', noCache: true, activeMenu: '/club/list' },
  107. hidden: true
  108. }
  109. ]
  110. },
  111. {
  112. path: '/goods',
  113. component: Layout,
  114. redirect: '/goods/list',
  115. name: 'Goods',
  116. meta: { title: '商品管理', icon: 'shopping' },
  117. children: [
  118. {
  119. path: 'category',
  120. name: 'Category',
  121. component: () => import('@/views/goods/category'),
  122. meta: { title: '商品分类', icon: 'component' }
  123. },
  124. {
  125. path: 'category/edit/:id(\\d+)',
  126. name: 'EditCategory',
  127. component: () => import('@/views/goods/category-edit'),
  128. meta: { title: '编辑分类', noCache: true, activeMenu: '/goods/category' },
  129. hidden: true
  130. },
  131. {
  132. path: 'category/create',
  133. name: 'CreateCategory',
  134. component: () => import('@/views/goods/category-create'),
  135. meta: { title: '添加分类', noCache: true, activeMenu: '/goods/category' },
  136. hidden: true
  137. },
  138. {
  139. path: 'list',
  140. name: 'List',
  141. component: () => import('@/views/goods/list'),
  142. meta: { title: '商品列表', icon: 'list' }
  143. },
  144. {
  145. path: 'list/preferred',
  146. name: 'PreferredProduct',
  147. component: () => import('@/views/goods/list-preferred'),
  148. meta: { title: '星范优惠', noCache: true, activeMenu: '/goods/list' },
  149. hidden: true
  150. },
  151. {
  152. path: 'list/preferential',
  153. name: 'PreferentialProduct',
  154. component: () => import('@/views/goods/list-preferential'),
  155. meta: { title: '星范精品', noCache: true, activeMenu: '/goods/list' },
  156. hidden: true
  157. },
  158. {
  159. path: 'list/commonly',
  160. name: 'CommonlyProduct',
  161. component: () => import('@/views/goods/list-commonly'),
  162. meta: { title: '常用商品', noCache: true, activeMenu: '/goods/list' },
  163. hidden: true
  164. },
  165. {
  166. path: 'list/select/:type(\\d+)',
  167. name: 'SelectProduct',
  168. component: () => import('@/views/goods/list-select'),
  169. meta: { title: '添加商品', noCache: true, activeMenu: '/goods/list' },
  170. hidden: true
  171. }
  172. ]
  173. },
  174. {
  175. path: '/order',
  176. component: Layout,
  177. redirect: '/order/list',
  178. name: 'Order',
  179. meta: { title: '订单管理', icon: 'documentation' },
  180. children: [
  181. {
  182. path: 'list',
  183. name: 'List',
  184. component: () => import('@/views/order/list'),
  185. meta: { title: '订单列表', icon: 'list' }
  186. },
  187. {
  188. path: 'refund',
  189. name: 'Refund',
  190. component: () => import('@/views/order/refund'),
  191. meta: { title: '用户退款列表', icon: 'skill' }
  192. },
  193. {
  194. path: 'refund/detail/:id(\\d+)',
  195. name: 'RefundDeatil',
  196. component: () => import('@/views/order/refund-detail'),
  197. meta: { title: '用户退款详情', noCache: true, activeMenu: '/order/refund' },
  198. hidden: true
  199. },
  200. {
  201. path: 'detail/:id(\\d+)',
  202. name: 'Detail',
  203. component: () => import('@/views/order/detail'),
  204. meta: { title: '订单详情', noCache: true, activeMenu: '/order/list' },
  205. hidden: true
  206. },
  207. {
  208. path: 'logistics/:id(\\d+)',
  209. name: 'logistics',
  210. component: () => import('@/views/order/logistics'),
  211. meta: { title: '发货记录', noCache: true, activeMenu: '/order/list' },
  212. hidden: true
  213. },
  214. {
  215. path: 'refund-record/:id(\\d+)',
  216. name: 'RefundRecord',
  217. component: () => import('@/views/order/refund-record'),
  218. meta: { title: '收退款记录', noCache: true, activeMenu: '/order/list' },
  219. hidden: true
  220. },
  221. {
  222. path: 'refund-return/:id(\\d+)',
  223. name: 'RefundRreturn',
  224. component: () => import('@/views/order/refund-return'),
  225. meta: { title: '退款(退货)记录', noCache: true, activeMenu: '/order/list' },
  226. hidden: true
  227. }
  228. ]
  229. },
  230. {
  231. path: '/finance',
  232. component: Layout,
  233. redirect: '/finance/list',
  234. name: 'Finance',
  235. meta: { title: '财务管理', icon: 'money' },
  236. children: [
  237. {
  238. path: 'list',
  239. name: 'List',
  240. component: () => import('@/views/finance/list'),
  241. meta: { title: '对账列表', icon: 'list' }
  242. },
  243. {
  244. path: 'refund',
  245. name: 'Refund',
  246. component: () => import('@/views/finance/refund'),
  247. meta: { title: '退款管理', icon: 'skill' }
  248. }
  249. ]
  250. },
  251. {
  252. path: '/other',
  253. component: Layout,
  254. redirect: '/other/about',
  255. name: 'Other',
  256. meta: { title: '其他设置', icon: 'example' },
  257. children: [
  258. {
  259. path: 'about',
  260. name: 'About',
  261. component: () => import('@/views/other/about'),
  262. meta: { title: '关于我们', icon: 'peoples' }
  263. },
  264. {
  265. path: 'after',
  266. name: 'After',
  267. component: () => import('@/views/other/after'),
  268. meta: { title: '售后无忧', icon: 'star' }
  269. },
  270. {
  271. path: 'notes',
  272. name: 'Notes',
  273. component: () => import('@/views/other/notes'),
  274. meta: { title: '购物须知', icon: 'form' }
  275. },
  276. {
  277. path: 'password',
  278. name: 'Password',
  279. component: () => import('@/views/other/password'),
  280. meta: { title: '修改密码', icon: 'eye' }
  281. }
  282. ]
  283. }
  284. ]
  285. /**
  286. * asyncRoutes
  287. * the routes that need to be dynamically loaded based on user roles
  288. */
  289. export const asyncRoutes = [
  290. // 404 page must be placed at the end !!!
  291. { path: '*', redirect: '/404', hidden: true }
  292. ]
  293. const createRouter = () => new Router({
  294. // mode: 'history', // require service support
  295. scrollBehavior: () => ({ y: 0 }),
  296. routes: constantRoutes
  297. })
  298. const router = createRouter()
  299. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  300. export function resetRouter() {
  301. const newRouter = createRouter()
  302. router.matcher = newRouter.matcher // reset router
  303. }
  304. export default router