index.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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 componentsRouter from './modules/components'
  8. import chartsRouter from './modules/charts'
  9. import tableRouter from './modules/table'
  10. import nestedRouter from './modules/nested'
  11. export const constantRoutes = [
  12. {
  13. path: '/redirect',
  14. component: Layout,
  15. hidden: true,
  16. children: [
  17. {
  18. path: '/redirect/:path(.*)',
  19. component: () => import('@/views/redirect/index')
  20. }
  21. ]
  22. },
  23. {
  24. path: '/login',
  25. component: () => import('@/views/login/index'),
  26. hidden: true
  27. },
  28. {
  29. path: '/auth-redirect',
  30. component: () => import('@/views/login/auth-redirect'),
  31. hidden: true
  32. },
  33. {
  34. path: '/404',
  35. component: () => import('@/views/error-page/404'),
  36. hidden: true
  37. },
  38. {
  39. path: '/401',
  40. component: () => import('@/views/error-page/401'),
  41. hidden: true
  42. },
  43. {
  44. path: '/',
  45. component: Layout,
  46. redirect: '/dashboard',
  47. children: [
  48. {
  49. path: 'dashboard',
  50. component: () => import('@/views/dashboard/index'),
  51. name: 'Dashboard',
  52. meta: { title: '主页', icon: 'dashboard', affix: true }
  53. }
  54. ]
  55. },
  56. {
  57. path: '/groupMeeting',
  58. component: Layout,
  59. redirect: '/groupMeeting/index',
  60. children: [
  61. {
  62. path: 'index',
  63. component: () => import('@/views/groupMeeting/index'),
  64. name: 'GroupMeeting',
  65. meta: {
  66. title: '组会管理',
  67. icon: 'guide',
  68. noCache: true
  69. }
  70. }
  71. ]
  72. },
  73. {
  74. path: '/invoiceRecord',
  75. component: Layout,
  76. redirect: '/invoiceRecord/index',
  77. children: [
  78. {
  79. path: 'index',
  80. component: () => import('@/views/invoiceRecord/index'),
  81. name: 'Guide',
  82. meta: {
  83. title: '发票管理',
  84. icon: 'skill',
  85. noCache: true
  86. }
  87. }
  88. ]
  89. },
  90. {
  91. path: '/guide',
  92. component: Layout,
  93. redirect: '/guide/index',
  94. hidden: true,
  95. children: [
  96. {
  97. path: 'index',
  98. component: () => import('@/views/guide/index'),
  99. name: 'Guide',
  100. meta: {
  101. title: '引导',
  102. icon: 'guide',
  103. noCache: true
  104. }
  105. }
  106. ]
  107. },
  108. {
  109. path: '/profile',
  110. component: Layout,
  111. redirect: '/profile/index',
  112. hidden: true,
  113. children: [
  114. {
  115. path: 'index',
  116. component: () => import('@/views/profile/index'),
  117. name: 'Profile',
  118. meta: { title: '个人中心', icon: 'user', noCache: true }
  119. }
  120. ]
  121. }
  122. ]
  123. export const asyncRoutes = [
  124. {
  125. path: '/permission',
  126. component: Layout,
  127. redirect: '/permission/page',
  128. alwaysShow: true,
  129. name: 'Permission',
  130. meta: {
  131. title: '权限管理',
  132. icon: 'lock',
  133. roles: ['admin', 'developer']
  134. },
  135. children: [
  136. {
  137. path: 'page',
  138. component: () => import('@/views/permission/page'),
  139. name: 'PagePermission',
  140. meta: {
  141. title: '页面权限',
  142. roles: ['admin', 'developer']
  143. }
  144. },
  145. {
  146. path: 'directive',
  147. component: () => import('@/views/permission/directive'),
  148. name: 'DirectivePermission',
  149. meta: {
  150. title: '指令权限',
  151. roles: ['admin', 'developer']
  152. }
  153. },
  154. {
  155. path: 'role',
  156. component: () => import('@/views/permission/role'),
  157. name: 'RolePermission',
  158. meta: {
  159. title: '角色权限',
  160. roles: ['admin']
  161. }
  162. }
  163. ]
  164. },
  165. {
  166. path: '/icon',
  167. component: Layout,
  168. children: [
  169. {
  170. path: 'index',
  171. component: () => import('@/views/icons/index'),
  172. name: 'Icons',
  173. meta: {
  174. title: '图标库',
  175. icon: 'icon',
  176. roles: ['developer'],
  177. noCache: true
  178. }
  179. }
  180. ]
  181. },
  182. componentsRouter,
  183. chartsRouter,
  184. nestedRouter,
  185. tableRouter,
  186. {
  187. path: '/example',
  188. component: Layout,
  189. redirect: '/example/list',
  190. name: 'Example',
  191. meta: {
  192. title: '示例中心',
  193. roles: ['developer'],
  194. icon: 'el-icon-s-help'
  195. },
  196. children: [
  197. {
  198. path: 'create',
  199. component: () => import('@/views/example/create'),
  200. name: 'CreateArticle',
  201. meta: { title: '创建文章', icon: 'edit' }
  202. },
  203. {
  204. path: 'edit/:id(\\d+)',
  205. component: () => import('@/views/example/edit'),
  206. name: 'EditArticle',
  207. meta: { title: '编辑文章', noCache: true, activeMenu: '/example/list' },
  208. hidden: true
  209. },
  210. {
  211. path: 'list',
  212. component: () => import('@/views/example/list'),
  213. name: 'ArticleList',
  214. meta: { title: '文章列表', icon: 'list' }
  215. }
  216. ]
  217. },
  218. {
  219. path: '/tab',
  220. component: Layout,
  221. children: [
  222. {
  223. path: 'index',
  224. component: () => import('@/views/tab/index'),
  225. name: 'Tab',
  226. meta: { title: '标签页管理', roles: ['developer'], icon: 'tab' }
  227. }
  228. ]
  229. },
  230. {
  231. path: '/error',
  232. component: Layout,
  233. redirect: 'noRedirect',
  234. name: 'ErrorPages',
  235. meta: {
  236. title: '错误页面',
  237. roles: ['developer'],
  238. icon: '404'
  239. },
  240. children: [
  241. {
  242. path: '401',
  243. component: () => import('@/views/error-page/401'),
  244. name: 'Page401',
  245. meta: { title: '401错误页', noCache: true }
  246. },
  247. {
  248. path: '404',
  249. component: () => import('@/views/error-page/404'),
  250. name: 'Page404',
  251. meta: { title: '404错误页', noCache: true }
  252. }
  253. ]
  254. },
  255. {
  256. path: '/error-log',
  257. component: Layout,
  258. children: [
  259. {
  260. path: 'log',
  261. component: () => import('@/views/error-log/index'),
  262. name: 'ErrorLog',
  263. meta: { title: '错误日志', roles: ['developer'], icon: 'bug' }
  264. }
  265. ]
  266. },
  267. {
  268. path: '/excel',
  269. component: Layout,
  270. redirect: '/excel/export-excel',
  271. name: 'Excel',
  272. meta: {
  273. title: 'Excel操作',
  274. roles: ['developer'],
  275. icon: 'excel'
  276. },
  277. children: [
  278. {
  279. path: 'export-excel',
  280. component: () => import('@/views/excel/export-excel'),
  281. name: 'ExportExcel',
  282. meta: { title: 'Excel导出' }
  283. },
  284. {
  285. path: 'export-selected-excel',
  286. component: () => import('@/views/excel/select-excel'),
  287. name: 'SelectExcel',
  288. meta: { title: '选择导出' }
  289. },
  290. {
  291. path: 'export-merge-header',
  292. component: () => import('@/views/excel/merge-header'),
  293. name: 'MergeHeader',
  294. meta: { title: '合并表头' }
  295. },
  296. {
  297. path: 'upload-excel',
  298. component: () => import('@/views/excel/upload-excel'),
  299. name: 'UploadExcel',
  300. meta: { title: 'Excel上传' }
  301. }
  302. ]
  303. },
  304. {
  305. path: '/zip',
  306. component: Layout,
  307. redirect: '/zip/download',
  308. alwaysShow: true,
  309. name: 'Zip',
  310. meta: { title: '压缩管理', roles: ['developer'], icon: 'zip' },
  311. children: [
  312. {
  313. path: 'download',
  314. component: () => import('@/views/zip/index'),
  315. name: 'ExportZip',
  316. meta: { title: '导出压缩' }
  317. }
  318. ]
  319. },
  320. {
  321. path: '/pdf',
  322. component: Layout,
  323. redirect: '/pdf/index',
  324. children: [
  325. {
  326. path: 'index',
  327. component: () => import('@/views/pdf/index'),
  328. name: 'PDF',
  329. meta: { title: 'PDF操作', roles: ['developer'], icon: 'pdf' }
  330. }
  331. ]
  332. },
  333. {
  334. path: '/pdf/download',
  335. component: () => import('@/views/pdf/download'),
  336. hidden: true
  337. },
  338. {
  339. path: '/theme',
  340. component: Layout,
  341. children: [
  342. {
  343. path: 'index',
  344. component: () => import('@/views/theme/index'),
  345. name: 'Theme',
  346. meta: { title: '主题设置', roles: ['developer'], icon: 'theme' }
  347. }
  348. ]
  349. },
  350. {
  351. path: '/clipboard',
  352. component: Layout,
  353. children: [
  354. {
  355. path: 'index',
  356. component: () => import('@/views/clipboard/index'),
  357. name: 'ClipboardDemo',
  358. meta: { title: '剪贴板', roles: ['developer'], icon: 'clipboard' }
  359. }
  360. ]
  361. },
  362. { path: '*', redirect: '/404', hidden: true }
  363. ]
  364. const createRouter = () =>
  365. new Router({
  366. scrollBehavior: () => ({ y: 0 }),
  367. routes: constantRoutes
  368. })
  369. const router = createRouter()
  370. export function resetRouter() {
  371. const newRouter = createRouter()
  372. router.matcher = newRouter.matcher
  373. }
  374. export default router