index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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: '/404',
  37. component: () => import('@/views/404'),
  38. hidden: true
  39. },
  40. {
  41. path: '/',
  42. component: Layout,
  43. redirect: '/dashboard',
  44. children: [{
  45. path: 'dashboard',
  46. name: 'Dashboard',
  47. component: () => import('@/views/dashboard/index'),
  48. meta: { title: '首页', icon: 'dashboard' }
  49. }]
  50. },
  51. {
  52. path: '/form',
  53. component: Layout,
  54. children: [
  55. {
  56. path: 'index',
  57. name: 'Form',
  58. component: () => import('@/views/form/index'),
  59. meta: { title: 'Form', icon: 'form' },
  60. hidden: true
  61. }
  62. ]
  63. },
  64. {
  65. path: '/join',
  66. component: Layout,
  67. children: [
  68. {
  69. path: 'list',
  70. name: 'join',
  71. component: () => import('@/views/join/list'),
  72. meta: { title: '加盟申请列表', icon: 'el-icon-s-help' }
  73. },
  74. {
  75. path: 'edit/:id(\\d+)',
  76. name: 'editJoin',
  77. component: () => import('@/views/join/edit'),
  78. meta: { title: '加盟申请查看', icon: 'el-icon-s-help' },
  79. hidden: true
  80. }
  81. ]
  82. },
  83. {
  84. path: '/advice',
  85. component: Layout,
  86. children: [
  87. {
  88. path: 'list',
  89. name: 'advice',
  90. component: () => import('@/views/advice/list'),
  91. meta: { title: '意见列表', icon: 'el-icon-s-help' }
  92. },
  93. {
  94. path: 'edit/:id(\\d+)',
  95. name: 'editAdvice',
  96. component: () => import('@/views/advice/edit'),
  97. meta: { title: '查看意见', icon: 'el-icon-s-help' },
  98. hidden: true
  99. }
  100. ]
  101. },
  102. {
  103. path: '/setting',
  104. component: Layout,
  105. name: 'setting',
  106. meta: {
  107. title: '小程序设置',
  108. icon: 'el-icon-setting'
  109. },
  110. children: [
  111. {
  112. path: 'edit',
  113. component: () => import('@/views/setting/edit'),
  114. name: 'CreateBanner',
  115. meta: { title: '关于我们', icon: 'el-icon-edit' }
  116. },
  117. {
  118. path: 'editServer',
  119. component: () => import('@/views/setting/editServer'),
  120. name: 'EditBanner',
  121. meta: { title: '服务协议', icon: 'el-icon-edit' }
  122. }
  123. ]
  124. },
  125. {
  126. path: '/banner',
  127. component: Layout,
  128. redirect: '/banner/list',
  129. name: 'article',
  130. meta: {
  131. title: '轮播设置',
  132. icon: 'el-icon-s-help'
  133. },
  134. children: [
  135. {
  136. path: 'create',
  137. component: () => import('@/views/banner/create'),
  138. name: 'CreateBanner',
  139. meta: { title: '创建轮播图', icon: 'el-icon-edit' }
  140. },
  141. {
  142. path: 'edit/:id(\\d+)',
  143. component: () => import('@/views/banner/edit'),
  144. name: 'EditBanner',
  145. meta: { title: '修改轮播图', noCache: true, activeMenu: '/banner/list' },
  146. hidden: true
  147. },
  148. {
  149. path: 'list',
  150. component: () => import('@/views/banner/list'),
  151. name: 'BannerList',
  152. meta: { title: '轮播图列表', icon: 'el-icon-s-order' }
  153. }
  154. ]
  155. },
  156. {
  157. path: '/question',
  158. component: Layout,
  159. redirect: '/banner/list',
  160. name: 'question',
  161. meta: {
  162. title: '常见疑问设置',
  163. icon: 'el-icon-s-help'
  164. },
  165. children: [
  166. {
  167. path: 'create',
  168. component: () => import('@/views/question/create'),
  169. name: 'CreateQuestion',
  170. meta: { title: '创建疑问', icon: 'el-icon-edit' }
  171. },
  172. {
  173. path: 'edit/:id(\\d+)',
  174. component: () => import('@/views/question/edit'),
  175. name: 'EditBanner',
  176. meta: { title: '修改疑问', noCache: true, activeMenu: '/question/list' },
  177. hidden: true
  178. },
  179. {
  180. path: 'list',
  181. component: () => import('@/views/question/list'),
  182. name: 'BannerList',
  183. meta: { title: '常见疑问列表', icon: 'el-icon-s-order' }
  184. }
  185. ]
  186. },
  187. {
  188. path: '/user',
  189. component: Layout,
  190. redirect: '/user/list',
  191. name: 'user',
  192. meta: {
  193. title: '用户',
  194. icon: 'el-icon-user'
  195. },
  196. children: [
  197. {
  198. path: 'create',
  199. component: () => import('@/views/user/create'),
  200. name: 'CreateUser',
  201. meta: { title: '创建用户', icon: 'el-icon-edit' },
  202. hidden: true
  203. },
  204. {
  205. path: 'edit/:id(\\d+)',
  206. component: () => import('@/views/user/edit'),
  207. name: 'EditUser',
  208. meta: { title: '修改用户', noCache: true, activeMenu: '/user/list' },
  209. hidden: true
  210. },
  211. {
  212. path: 'list',
  213. component: () => import('@/views/user/list'),
  214. name: 'UserList',
  215. meta: { title: '用户列表', icon: 'el-icon-s-order' }
  216. }
  217. ]
  218. },
  219. {
  220. path: '/article',
  221. component: Layout,
  222. redirect: '/article/list',
  223. name: 'article',
  224. meta: {
  225. title: '咨询信息',
  226. icon: 'el-icon-reading'
  227. },
  228. children: [
  229. {
  230. path: 'create',
  231. component: () => import('@/views/article/create'),
  232. name: 'CreateArticle',
  233. meta: { title: '创建文章', icon: 'el-icon-edit' }
  234. },
  235. {
  236. path: 'edit/:id(\\d+)',
  237. component: () => import('@/views/article/edit'),
  238. name: 'EditArticle',
  239. meta: { title: '修改文章', noCache: true, activeMenu: '/article/list' },
  240. hidden: true
  241. },
  242. {
  243. path: 'list',
  244. component: () => import('@/views/article/list'),
  245. name: 'ArticleList',
  246. meta: { title: '文章列表', icon: 'el-icon-s-order' }
  247. }
  248. ]
  249. },
  250. {
  251. path: '/video',
  252. component: Layout,
  253. redirect: '/video/list',
  254. name: 'video',
  255. meta: {
  256. title: '短视频',
  257. icon: 'el-icon-video-camera'
  258. },
  259. children: [
  260. {
  261. path: 'create',
  262. component: () => import('@/views/video/create'),
  263. name: 'CreateVideo',
  264. meta: { title: '创建短视频', icon: 'el-icon-edit' }
  265. },
  266. {
  267. path: 'edit/:id(\\d+)',
  268. component: () => import('@/views/video/edit'),
  269. name: 'EditVideo',
  270. meta: { title: '修改短视频', noCache: true, activeMenu: '/video/list' },
  271. hidden: true
  272. },
  273. {
  274. path: 'list',
  275. component: () => import('@/views/video/list'),
  276. name: 'VideoList',
  277. meta: { title: '短视频列表', icon: 'el-icon-s-order' }
  278. }
  279. ]
  280. },
  281. // 404 page must be placed at the end !!!
  282. { path: '*', redirect: '/404', hidden: true }
  283. ]
  284. const createRouter = () => new Router({
  285. // mode: 'history', // require service support
  286. scrollBehavior: () => ({ y: 0 }),
  287. routes: constantRoutes
  288. })
  289. const router = createRouter()
  290. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  291. export function resetRouter() {
  292. const newRouter = createRouter()
  293. router.matcher = newRouter.matcher // reset router
  294. }
  295. export default router