router.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import { RouterTabRoutes } from '../src'
  4. const importPage = view => () => import(/* webpackChunkName: "p-[request]" */ `./views/${view}.vue`)
  5. const importLayout = view => () => import(/* webpackChunkName: "ly-[request]" */ `./components/layout/${view}.vue`)
  6. Vue.use(Router)
  7. // 路由页面
  8. let pageRoutes = [{
  9. path: 'page/:id',
  10. component: importPage('Page'),
  11. meta: {
  12. title: '页面',
  13. icon: 'rt-icon-doc'
  14. }
  15. }, {
  16. path: 'rule/:catalog/:type',
  17. component: importPage('Rule'),
  18. meta: {
  19. title: '默认规则',
  20. icon: 'rt-icon-log'
  21. }
  22. }, {
  23. path: 'route-rule/:catalog/:type',
  24. component: importPage('Rule'),
  25. meta: {
  26. title: '路由规则',
  27. icon: 'rt-icon-log',
  28. aliveId (route) {
  29. return `route-rule/${route.params.catalog}`
  30. }
  31. }
  32. }, {
  33. path: 'tab-dynamic',
  34. component: importPage('TabDynamic'),
  35. meta: {
  36. title: '动态更新页签',
  37. icon: 'rt-icon-log'
  38. }
  39. }, {
  40. path: 'page-leave',
  41. component: importPage('PageLeave'),
  42. meta: {
  43. title: '页面离开确认',
  44. icon: 'rt-icon-contact'
  45. }
  46. }, ...RouterTabRoutes]
  47. export default new Router({
  48. routes: [{
  49. path: '/',
  50. redirect: '/default/page/1'
  51. }, {
  52. path: '/default/',
  53. component: importLayout('Default'),
  54. redirect: '/default/page/1',
  55. children: pageRoutes
  56. }, {
  57. path: '/transition/',
  58. component: importLayout('Transition'),
  59. redirect: '/transition/page/1',
  60. children: pageRoutes
  61. }, {
  62. path: '/initial-tabs/',
  63. component: importLayout('InitialTabs'),
  64. redirect: '/initial-tabs/page/1',
  65. children: pageRoutes
  66. }, {
  67. path: '/lang-en/',
  68. component: importLayout('LangEn'),
  69. redirect: '/lang-en/page/1',
  70. children: pageRoutes
  71. }, {
  72. path: '/lang-custom/',
  73. component: importLayout('LangCustom'),
  74. redirect: '/lang-custom/page/1',
  75. children: pageRoutes
  76. }, {
  77. path: '/slot/',
  78. component: importLayout('Slot'),
  79. redirect: '/slot/page/1',
  80. children: pageRoutes
  81. }, {
  82. path: '/global-rule/',
  83. component: importLayout('GlobalRule'),
  84. redirect: '/global-rule/rule/a/1',
  85. children: pageRoutes
  86. }, {
  87. path: '/404',
  88. component: importPage('404'),
  89. meta: {
  90. title: '找不到页面',
  91. icon: 'rt-icon-warning'
  92. }
  93. }, {
  94. path: '*',
  95. redirect: '/404'
  96. }]
  97. })