user.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { MockMethod } from 'vite-plugin-mock';
  2. import { resultSuccess } from '../_util';
  3. const fakeCodeList: any = {
  4. '1': ['1000', '3000', '5000'],
  5. '2': ['2000', '4000', '6000'],
  6. };
  7. export default [
  8. {
  9. url: '/sys-api/user/perm',
  10. timeout: 200,
  11. method: 'get',
  12. response: () => {
  13. return resultSuccess(fakeCodeList['1'], { msg: 'success' });
  14. },
  15. },
  16. // mock user login example
  17. // {
  18. // url: '/sys-api/user/login',
  19. // timeout: 200,
  20. // method: 'post',
  21. // response: ({ body }) => {
  22. // const { username, password } = body;
  23. // const checkUser = createFakeUserList().find(
  24. // (item) => item.username === username && password === item.password,
  25. // );
  26. // if (!checkUser) {
  27. // return resultError('Incorrect account or password!');
  28. // }
  29. // const { userId, username: _username, token, realName, desc, roles } = checkUser;
  30. // return resultSuccess({
  31. // roles,
  32. // userId,
  33. // username: _username,
  34. // token,
  35. // realName,
  36. // desc,
  37. // });
  38. // },
  39. // },
  40. ] as MockMethod[];