You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
879 B

  1. import { MockMethod } from "vite-plugin-mock";
  2. // 模拟刷新token接口
  3. export default [
  4. {
  5. url: "/refreshToken",
  6. method: "post",
  7. response: ({ body }) => {
  8. if (body.refreshToken) {
  9. return {
  10. success: true,
  11. data: {
  12. accessToken: "eyJhbGciOiJIUzUxMiJ9.newAdmin",
  13. refreshToken: "eyJhbGciOiJIUzUxMiJ9.newAdminRefresh",
  14. // `expires`选择这种日期格式是为了方便调试,后端直接设置时间戳或许更方便(每次都应该递增)。如果后端返回的是时间戳格式,前端开发请来到这个目录`src/utils/auth.ts`,把第`38`行的代码换成expires = data.expires即可。
  15. expires: "2023/10/30 23:59:59"
  16. }
  17. };
  18. } else {
  19. return {
  20. success: false,
  21. data: {}
  22. };
  23. }
  24. }
  25. }
  26. ] as MockMethod[];