user.ts 511 B

1234567891011121314151617181920212223
  1. import { MockMethod } from "vite-plugin-mock";
  2. export default [
  3. {
  4. url: "/login",
  5. method: "post",
  6. response: ({ body }) => {
  7. if (body.username === "admin") {
  8. return {
  9. username: "admin",
  10. expires: 24 * 60 * 60,
  11. accessToken: "eyJhbGciOiJIUzUxMiJ9.admin"
  12. };
  13. } else {
  14. return {
  15. username: "test",
  16. expires: 24 * 60 * 60,
  17. accessToken: "eyJhbGciOiJIUzUxMiJ9.test"
  18. };
  19. }
  20. }
  21. }
  22. ] as MockMethod[];