menu.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import { resultSuccess } from '../_util';
  2. import { MockMethod } from 'vite-plugin-mock';
  3. const dashboardRoute = {
  4. layout: {
  5. path: '/dashboard',
  6. name: 'Dashboard',
  7. component: 'PAGE_LAYOUT',
  8. redirect: '/dashboard/welcome',
  9. meta: {
  10. icon: 'ant-design:home-outlined',
  11. title: 'Dashboard',
  12. },
  13. },
  14. routes: [
  15. {
  16. path: '/welcome',
  17. name: 'Welcome',
  18. component: '/dashboard/welcome/index.vue',
  19. meta: {
  20. title: '欢迎页',
  21. affix: true,
  22. },
  23. },
  24. ],
  25. };
  26. const frontRoute = {
  27. path: '/front',
  28. name: 'PermissionFrontDemo',
  29. meta: {
  30. title: '基于前端权限',
  31. },
  32. children: [
  33. {
  34. path: 'page',
  35. component: '/demo/permission/front/index.vue',
  36. meta: {
  37. title: '页面权限',
  38. },
  39. },
  40. {
  41. path: 'btn',
  42. component: '/demo/permission/front/Btn.vue',
  43. meta: {
  44. title: '按钮权限',
  45. },
  46. },
  47. {
  48. path: 'auth-pageA',
  49. component: '/demo/permission/front/AuthPageA.vue',
  50. meta: {
  51. title: '权限测试页A',
  52. },
  53. },
  54. {
  55. path: 'auth-pageB',
  56. component: '/demo/permission/front/AuthPageB.vue',
  57. meta: {
  58. title: '权限测试页B',
  59. },
  60. },
  61. ],
  62. };
  63. const backRoute = {
  64. path: '/back',
  65. name: 'PermissionBackDemo',
  66. meta: {
  67. title: '基于后台权限',
  68. },
  69. children: [
  70. {
  71. path: 'page',
  72. component: 'demo/permission/back/index.vue',
  73. meta: {
  74. title: '页面权限',
  75. },
  76. },
  77. {
  78. path: 'btn',
  79. component: '/demo/permission/back/Btn.vue',
  80. meta: {
  81. title: '按钮权限',
  82. },
  83. },
  84. ],
  85. };
  86. const authRoute = {
  87. layout: {
  88. path: '/permission',
  89. name: 'Permission',
  90. component: 'PAGE_LAYOUT',
  91. redirect: '/permission/front/page',
  92. meta: {
  93. icon: 'ant-design:home-outlined',
  94. title: '权限管理',
  95. },
  96. },
  97. routes: [frontRoute, backRoute],
  98. };
  99. const authRoute1 = {
  100. layout: {
  101. path: '/permission',
  102. name: 'Permission',
  103. component: 'PAGE_LAYOUT',
  104. redirect: '/permission/front/page',
  105. meta: {
  106. icon: 'ant-design:home-outlined',
  107. title: '权限管理',
  108. },
  109. },
  110. routes: [backRoute],
  111. };
  112. export default [
  113. {
  114. url: '/api/getMenuListById',
  115. timeout: 1000,
  116. method: 'get',
  117. response: ({ query }) => {
  118. const { id } = query;
  119. if (!id || id === '1') {
  120. return resultSuccess([dashboardRoute, authRoute]);
  121. }
  122. if (id === '2') {
  123. return resultSuccess([dashboardRoute, authRoute1]);
  124. }
  125. },
  126. },
  127. ] as MockMethod[];