route.ts 720 B

1234567891011121314151617181920212223242526272829
  1. import type { MockMethod } from 'vite-plugin-mock';
  2. import { routeModel, userModel } from '../model';
  3. const apis: MockMethod[] = [
  4. {
  5. url: '/mock/getUserRoutes',
  6. method: 'post',
  7. response: (options: Service.MockOption): Service.MockServiceResult => {
  8. const { userId = undefined } = options.body;
  9. const routeHomeName: AuthRoute.LastDegreeRouteKey = 'dashboard_analysis';
  10. const role = userModel.find(item => item.userId === userId)?.userRole || 'user';
  11. const filterRoutes = routeModel[role];
  12. return {
  13. code: 200,
  14. message: 'ok',
  15. data: {
  16. routes: filterRoutes,
  17. home: routeHomeName
  18. }
  19. };
  20. }
  21. }
  22. ];
  23. export default apis;