router.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. const importPage = view => () => import(/* webpackChunkName: "p-[request]" */ `./views/${view}.vue`)
  4. const importLayout = view => () => import(/* webpackChunkName: "ly-[request]" */ `./components/layout/${view}.vue`)
  5. Vue.use(Router)
  6. // 路由页面
  7. let pageRoutes = [{
  8. path: 'page/:id',
  9. component: importPage('Page'),
  10. meta: {
  11. title: '页面',
  12. icon: 'rt-icon-doc'
  13. }
  14. }, {
  15. path: 'tab-dynamic',
  16. component: importPage('TabDynamic'),
  17. meta: {
  18. title: '动态更新页签',
  19. icon: 'rt-icon-log'
  20. }
  21. }, {
  22. path: 'page-leave',
  23. component: importPage('PageLeave'),
  24. meta: {
  25. title: '页面离开提示',
  26. icon: 'rt-icon-contact'
  27. }
  28. }]
  29. export default new Router({
  30. routes: [{
  31. path: '/',
  32. redirect: '/default/page/1'
  33. }, {
  34. path: '/default/',
  35. component: importLayout('Default'),
  36. redirect: '/default/page/1',
  37. children: pageRoutes
  38. }, {
  39. path: '/initial-tabs/',
  40. component: importLayout('InitialTabs'),
  41. redirect: '/initial-tabs/page/1',
  42. children: pageRoutes
  43. }, {
  44. path: '/language/',
  45. component: importLayout('Language'),
  46. redirect: '/language/page/1',
  47. children: pageRoutes
  48. }, {
  49. path: '/language/custom/',
  50. component: importLayout('LanguageCustom'),
  51. redirect: '/language/custom/page/1',
  52. children: pageRoutes
  53. }, {
  54. path: '/slot/',
  55. component: importLayout('Slot'),
  56. redirect: '/slot/page/1',
  57. children: pageRoutes
  58. }, {
  59. path: '/404',
  60. component: importPage('404'),
  61. meta: {
  62. title: '找不到页面',
  63. icon: 'rt-icon-warning'
  64. }
  65. }, {
  66. path: '*',
  67. redirect: '/404'
  68. }]
  69. })