asyncRoutes.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/index",
  26. name: "PermissionButton",
  27. meta: {
  28. title: "按钮权限",
  29. roles: ["admin", "common"],
  30. auths: [
  31. "permission:btn:add",
  32. "permission:btn:edit",
  33. "permission:btn:delete"
  34. ]
  35. }
  36. }
  37. ]
  38. };
  39. export default defineFakeRoute([
  40. {
  41. url: "/get-async-routes",
  42. method: "get",
  43. response: () => {
  44. return {
  45. success: true,
  46. data: [permissionRouter]
  47. };
  48. }
  49. }
  50. ]);