menu.ts 2.4 KB

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