asyncRoutes.ts 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // 模拟后端动态生成路由
  2. import { MockMethod } from "vite-plugin-mock";
  3. /**
  4. * roles:页面级别权限,这里模拟二种 "admin"、"common"
  5. * admin:管理员角色
  6. * common:普通角色
  7. */
  8. const permissionRouter = {
  9. path: "/permission",
  10. meta: {
  11. title: "权限管理",
  12. icon: "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/index",
  26. name: "PermissionButton",
  27. meta: {
  28. title: "按钮权限",
  29. roles: ["admin", "common"],
  30. auths: ["btn_add", "btn_edit", "btn_delete"]
  31. }
  32. }
  33. ]
  34. };
  35. export default [
  36. {
  37. url: "/getAsyncRoutes",
  38. method: "get",
  39. response: () => {
  40. return {
  41. success: true,
  42. data: [permissionRouter]
  43. };
  44. }
  45. }
  46. ] as MockMethod[];