index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /* Router Modules */
  7. import memberRouter from '@/router/modules/member'
  8. import configRouter from '@/router/modules/config'
  9. /**
  10. * Note: sub-menu only appear when route children.length >= 1
  11. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  12. *
  13. * hidden: true if set true, item will not show in the sidebar(default is false)
  14. * alwaysShow: true if set true, will always show the root menu
  15. * if not set alwaysShow, when item has more than one children route,
  16. * it will becomes nested mode, otherwise not show the root menu
  17. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  18. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  19. * meta : {
  20. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  21. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  22. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  23. noCache: true if set true, the page will no be cached(default is false)
  24. affix: true if set true, the tag will affix in the tags-view
  25. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  26. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  27. }
  28. */
  29. /**
  30. * constantRoutes
  31. * a base page that does not have permission requirements
  32. * all roles can be accessed
  33. */
  34. export const constantRoutes = [
  35. {
  36. path: '/redirect',
  37. component: Layout,
  38. hidden: true,
  39. children: [
  40. {
  41. path: '/redirect/:path(.*)',
  42. component: () => import('@/views/redirect/index')
  43. }
  44. ]
  45. },
  46. {
  47. path: '/admin',
  48. component: Layout,
  49. hidden: true,
  50. children: [
  51. {
  52. path: '/admin/role',
  53. component: () => import('@/views/admin/role') // 管理员角色列表
  54. },
  55. {
  56. path: '/admin/role-add',
  57. component: () => import('@/views/admin/role-add') // 添加角色
  58. },
  59. {
  60. path: '/admin/role-edit/:id',
  61. name: 'admin_role-edit',
  62. component: () => import('@/views/admin/role-add') // 编辑角色
  63. },
  64. {
  65. path: '/admin/role-permission/:id',
  66. name: 'admin_role-permission',
  67. component: () => import('@/views/admin/role-permission') // 角色权限
  68. },
  69. {
  70. path: '/admin/change-password',
  71. name: 'admin_change-password',
  72. component: () => import('@/views/admin/edit') // 重置密码
  73. },
  74. {
  75. path: '/admin/index',
  76. name: 'admin_index',
  77. component: () => import('@/views/admin/index') // 管理员列表
  78. },
  79. {
  80. path: '/admin/add',
  81. name: 'admin_add',
  82. component: () => import('@/views/admin/edit') // 添加管理员
  83. },
  84. {
  85. path: '/admin/edit/:id',
  86. name: 'admin_edit',
  87. component: () => import('@/views/admin/edit') // 编辑管理员
  88. }
  89. ]
  90. },
  91. {
  92. path: '/finance',
  93. component: Layout,
  94. hidden: true,
  95. children: [
  96. {
  97. path: '/finance/balance-audit-list', // 会员余额调整列表
  98. component: () => import('@/views/finance/balance-audit-list'),
  99. name: 'finance_balance-audit-list',
  100. },
  101. {
  102. path: '/finance/change-balance-opt', // 申请调整会员余额
  103. component: () => import('@/views/finance/change-balance-opt'),
  104. name: 'finance_change-balance-opt',
  105. },
  106. {
  107. path: '/finance/transfer-list', // 转账记录列表
  108. component: () => import('@/views/finance/transfer-list'),
  109. name: 'finance_transfer-list',
  110. },
  111. {
  112. path: '/finance/recharge', // 充值管理
  113. component: () => import('@/views/finance/recharge'),
  114. name: 'finance_recharge',
  115. },
  116. {
  117. path: '/finance/recharge-status', // 状态管理
  118. component: () => import('@/views/finance/recharge-status'),
  119. name: 'finance_recharge-status',
  120. },
  121. {
  122. path: '/finance/withdraw', // 提现管理
  123. component: () => import('@/views/finance/withdraw'),
  124. name: 'finance_withdraw',
  125. },
  126. ]
  127. },
  128. {
  129. path: '/atlas',
  130. component: Layout,
  131. hidden: true,
  132. children: [
  133. {
  134. path: '/atlas/relation-opt', // 开拓网络
  135. component: () => import('@/views/atlas/relation-opt'),
  136. name: 'atlas_relation-opt',
  137. },
  138. {
  139. path: '/atlas/network-opt', // 安置网络
  140. component: () => import('@/views/atlas/network-opt'),
  141. name: 'atlas_network-opt',
  142. },
  143. ]
  144. },
  145. {
  146. path: '/login',
  147. component: () => import('@/views/login/index'),
  148. hidden: true
  149. },
  150. {
  151. path: '/auth-redirect',
  152. component: () => import('@/views/login/auth-redirect'),
  153. hidden: true
  154. },
  155. {
  156. path: '/404',
  157. component: () => import('@/views/error-page/404'),
  158. hidden: true
  159. },
  160. {
  161. path: '/401',
  162. component: () => import('@/views/error-page/401'),
  163. hidden: true
  164. },
  165. {
  166. path: '/',
  167. component: Layout,
  168. redirect: '/dashboard',
  169. children: [
  170. {
  171. path: '/dashboard/index',
  172. component: () => import('@/views/dashboard/index'),
  173. name: 'Dashboard',
  174. meta: { title: 'dashboard', icon: 'dashboard', affix: true }
  175. }
  176. ]
  177. },
  178. {
  179. path: '/profile',
  180. component: Layout,
  181. redirect: '/profile/index',
  182. hidden: true,
  183. children: [
  184. {
  185. path: 'index',
  186. component: () => import('@/views/profile/index'),
  187. name: 'Profile',
  188. meta: { title: 'profile', icon: 'user', noCache: true }
  189. }
  190. ]
  191. }
  192. ]
  193. /**
  194. * asyncRoutes
  195. * the routes that need to be dynamically loaded based on user roles
  196. */
  197. export const asyncRoutes = [
  198. /** when your routing map is too long, you can split it into small modules **/
  199. // 会员
  200. memberRouter,
  201. // 设置
  202. configRouter,
  203. {
  204. path: '/example',
  205. component: Layout,
  206. redirect: '/example/list',
  207. name: 'Example',
  208. meta: {
  209. title: 'example',
  210. icon: 'el-icon-s-help'
  211. },
  212. children: [
  213. {
  214. path: 'create',
  215. component: () => import('@/views/example/create'),
  216. name: 'CreateArticle',
  217. meta: { title: 'createArticle', icon: 'edit' }
  218. },
  219. {
  220. path: 'edit/:id(\\d+)',
  221. component: () => import('@/views/example/edit'),
  222. name: 'EditArticle',
  223. meta: { title: 'editArticle', noCache: true, activeMenu: '/example/list' },
  224. hidden: true
  225. },
  226. {
  227. path: 'list',
  228. component: () => import('@/views/example/list'),
  229. name: 'ArticleList',
  230. meta: { title: 'articleList', icon: 'list' }
  231. }
  232. ]
  233. },
  234. {
  235. path: '/ad',
  236. component: Layout,
  237. redirect: '/ad/list',
  238. hidden: true,
  239. children: [
  240. {
  241. path: 'location',
  242. component: () => import('@/views/ad/index'),
  243. name: 'ad-location',
  244. meta: { title: 'adLocation', icon: 'user', noCache: true }
  245. },
  246. {
  247. path: 'list/:ID(\\w+)',
  248. component: () => import('@/views/ad/list'),
  249. name: 'ad-list',
  250. meta: { title: 'adList', noCache: true, activeMenu: '/ad/location' },
  251. hidden: true
  252. },
  253. {
  254. path: 'edit/:ID(\\w+)',
  255. component: () => import('@/views/ad/edit'),
  256. name: 'ad-edit',
  257. meta: { title: 'adEdit', noCache: true, activeMenu: '/ad/location' },
  258. hidden: true
  259. },
  260. {
  261. path: 'add',
  262. component: () => import('@/views/ad/edit'),
  263. name: 'ad-add',
  264. meta: { title: 'adAdd', noCache: true, activeMenu: '/ad/location' },
  265. hidden: true
  266. }
  267. ]
  268. },
  269. {
  270. path: '/log',
  271. component: Layout,
  272. redirect: '/log/admin-login',
  273. hidden: true,
  274. children: [
  275. {
  276. path: 'admin-login',
  277. component: () => import('@/views/log/admin-login'),
  278. name: 'admin-login',
  279. meta: { title: 'admin-login', icon: 'user', noCache: true }
  280. },
  281. {
  282. path: 'user-login',
  283. component: () => import('@/views/log/user-login'),
  284. name: 'user-login',
  285. meta: { title: 'user-login', icon: 'user', noCache: true }
  286. },
  287. {
  288. path: 'admin-handle',
  289. component: () => import('@/views/log/admin-handle'),
  290. name: 'admin-handle',
  291. meta: { title: 'admin-handle', icon: 'user', noCache: true }
  292. },
  293. {
  294. path: 'user-handle',
  295. component: () => import('@/views/log/user-handle'),
  296. name: 'user-handle',
  297. meta: { title: 'user-handle', icon: 'user', noCache: true }
  298. },
  299. {
  300. path: 'system',
  301. component: () => import('@/views/log/system'),
  302. name: 'system',
  303. meta: { title: 'system', icon: 'user', noCache: true }
  304. }
  305. ]
  306. },
  307. {
  308. path: '/article',
  309. component: Layout,
  310. redirect: '/article/category',
  311. hidden: true,
  312. children: [
  313. {
  314. path: 'category',
  315. component: () => import('@/views/article/category'),
  316. name: 'category',
  317. meta: { title: 'category', icon: 'user', noCache: true }
  318. },
  319. {
  320. path: 'index',
  321. component: () => import('@/views/article/index'),
  322. name: 'index',
  323. meta: { title: 'index', icon: 'user', noCache: true }
  324. },
  325. {
  326. path: 'edit/:ID(\\w+)',
  327. component: () => import('@/views/article/edit'),
  328. name: 'edit',
  329. meta: { title: 'edit', noCache: true },
  330. hidden: true
  331. },
  332. {
  333. path: 'add',
  334. component: () => import('@/views/article/edit'),
  335. name: 'add',
  336. meta: { title: 'edit', noCache: true },
  337. hidden: true
  338. }
  339. ]
  340. },
  341. {
  342. path: '/file',
  343. component: Layout,
  344. redirect: '/file/export',
  345. hidden: true,
  346. children: [
  347. {
  348. path: 'export',
  349. component: () => import('@/views/file/export'),
  350. name: 'export',
  351. meta: { title: 'export', noCache: true }
  352. }
  353. ]
  354. },
  355. {
  356. path: '/bonus',
  357. component: Layout,
  358. redirect: '/bonus/balance-list',
  359. hidden: true,
  360. children: [
  361. {
  362. path: 'balance-list',
  363. component: () => import('@/views/bonus/balance-list'),
  364. name: 'balance-list',
  365. meta: { title: 'balance-list', noCache: true }
  366. },
  367. {
  368. path: 'other-period-bonus',
  369. component: () => import('@/views/bonus/other-period-bonus'),
  370. name: 'other-period-bonus',
  371. meta: { title: 'other-period-bonus', noCache: true }
  372. },
  373. {
  374. path: 'flow-bonus',
  375. component: () => import('@/views/bonus/flow-bonus'),
  376. name: 'flow-bonus',
  377. meta: { title: 'flow-bonus', noCache: true }
  378. },
  379. {
  380. path: 'user-perf',
  381. component: () => import('@/views/bonus/user-perf'),
  382. name: 'user-perf',
  383. meta: { title: 'user-perf', noCache: true }
  384. },
  385. {
  386. path: 'perf-order',
  387. component: () => import('@/views/bonus/perf-order'),
  388. name: 'perf-order',
  389. meta: { title: 'perf-order', noCache: true }
  390. },
  391. {
  392. path: 'perf-period-list',
  393. component: () => import('@/views/bonus/perf-period-list'),
  394. name: 'perf-period-list',
  395. meta: { title: 'perf-period-list', noCache: true }
  396. },
  397. {
  398. path: 'perf-month',
  399. component: () => import('@/views/bonus/perf-month'),
  400. name: 'perf-month',
  401. meta: { title: 'perf-month', noCache: true }
  402. },
  403. {
  404. path: 'perf-adjustment',
  405. component: () => import('@/views/bonus/perf-adjustment'),
  406. name: 'perf-adjustment',
  407. meta: { title: 'perf-adjustment', noCache: true }
  408. }
  409. ]
  410. },
  411. {
  412. path: '/tab',
  413. component: Layout,
  414. children: [
  415. {
  416. path: 'index',
  417. component: () => import('@/views/tab/index'),
  418. name: 'Tab',
  419. meta: { title: 'tab', icon: 'tab' }
  420. }
  421. ]
  422. },
  423. {
  424. path: '/error',
  425. component: Layout,
  426. redirect: 'noRedirect',
  427. name: 'ErrorPages',
  428. meta: {
  429. title: 'errorPages',
  430. icon: '404'
  431. },
  432. children: [
  433. {
  434. path: '401',
  435. component: () => import('@/views/error-page/401'),
  436. name: 'Page401',
  437. meta: { title: 'page401', noCache: true }
  438. },
  439. {
  440. path: '404',
  441. component: () => import('@/views/error-page/404'),
  442. name: 'Page404',
  443. meta: { title: 'page404', noCache: true }
  444. }
  445. ]
  446. },
  447. {
  448. path: '/error-log',
  449. component: Layout,
  450. children: [
  451. {
  452. path: 'log',
  453. component: () => import('@/views/error-log/index'),
  454. name: 'ErrorLog',
  455. meta: { title: 'errorLog', icon: 'bug' }
  456. }
  457. ]
  458. },
  459. // 404 page must be placed at the end !!!
  460. { path: '*', redirect: '/404', hidden: true }
  461. ]
  462. const createRouter = () => new Router({
  463. // mode: 'history', // require service support
  464. scrollBehavior: () => ({ y: 0 }),
  465. routes: constantRoutes.concat(asyncRoutes)
  466. })
  467. const router = createRouter()
  468. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  469. export function resetRouter() {
  470. const newRouter = createRouter()
  471. router.matcher = newRouter.matcher // reset router
  472. }
  473. export function selfAddRoutes(params) {
  474. const newRouter = createRouter()
  475. router.matcher = newRouter.matcher
  476. router.addRoutes(params)
  477. }
  478. export default router