asyncRoutes.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // 模拟后端动态生成路由
  2. import { defineFakeRoute } from "vite-plugin-fake-server/client";
  3. /**
  4. * roles:页面级别权限,这里模拟二种 "admin"、"common"
  5. * admin:管理员角色
  6. * common:普通角色
  7. */
  8. const permissionRouter = {
  9. path: "/permission",
  10. meta: {
  11. title: "权限管理",
  12. icon: "ep:lollipop",
  13. rank: 10
  14. },
  15. children: [
  16. {
  17. path: "/permission/page/index",
  18. name: "PermissionPage",
  19. meta: {
  20. title: "页面权限",
  21. roles: ["admin", "common"]
  22. }
  23. },
  24. {
  25. path: "/permission/button",
  26. meta: {
  27. title: "按钮权限",
  28. roles: ["admin", "common"]
  29. },
  30. children: [
  31. {
  32. path: "/permission/button/router",
  33. component: "permission/button/index",
  34. name: "PermissionButtonRouter",
  35. meta: {
  36. title: "路由返回按钮权限",
  37. auths: [
  38. "permission:btn:add",
  39. "permission:btn:edit",
  40. "permission:btn:delete"
  41. ]
  42. }
  43. },
  44. {
  45. path: "/permission/button/login",
  46. component: "permission/button/perms",
  47. name: "PermissionButtonLogin",
  48. meta: {
  49. title: "登录接口返回按钮权限"
  50. }
  51. }
  52. ]
  53. }
  54. ]
  55. };
  56. const messagePlatform = {
  57. path: "/messagePlatform",
  58. meta: {
  59. title: "消息平台",
  60. icon: "ep:lollipop",
  61. rank: 10
  62. },
  63. children: [
  64. {
  65. path: "/messagePlatform/gateways",
  66. component: "messageGateways/index",
  67. name: "messageGatewaysRouter",
  68. meta: {
  69. title: "消息网关管理",
  70. roles: ["admin", "common"]
  71. }
  72. },
  73. {
  74. path: "/messagePlatform/textMessage",
  75. component: "textMessage/index",
  76. name: "textMessageRouter",
  77. meta: {
  78. title: "短信模板管理",
  79. roles: ["admin", "common"]
  80. }
  81. },
  82. {
  83. path: "/messagePlatform/applicationMange",
  84. component: "applicationMange/index",
  85. name: "applicationRouter",
  86. meta: {
  87. title: "应用管理",
  88. roles: ["admin", "common"]
  89. }
  90. },
  91. {
  92. path: "/messagePlatform/dynamicAttribute",
  93. component: "dynamicAttribute/index",
  94. name: "dynamicAttributeRouter",
  95. meta: {
  96. title: "动态属性管理",
  97. roles: ["admin", "common"]
  98. }
  99. },
  100. {
  101. path: "/messagePlatform/system",
  102. component: "system/index",
  103. name: "systemRouter",
  104. meta: {
  105. title: "系统设置",
  106. roles: ["admin", "common"]
  107. }
  108. }
  109. ]
  110. };
  111. export default defineFakeRoute([
  112. {
  113. url: "/get-async-routes",
  114. method: "get",
  115. response: () => {
  116. return {
  117. success: true,
  118. data: [messagePlatform]
  119. };
  120. }
  121. }
  122. ]);