wireguard-dashboard-admin/mock/refreshToken.ts

28 lines
900 B
TypeScript
Raw Permalink Normal View History

2024-03-09 16:27:52 +08:00
import { defineFakeRoute } from "vite-plugin-fake-server/client";
2022-10-25 17:51:21 +08:00
// 模拟刷新token接口
2024-03-09 16:27:52 +08:00
export default defineFakeRoute([
2022-10-25 17:51:21 +08:00
{
2024-03-09 16:27:52 +08:00
url: "/refresh-token",
2022-10-25 17:51:21 +08:00
method: "post",
response: ({ body }) => {
if (body.refreshToken) {
return {
success: true,
data: {
2022-11-01 16:29:32 +08:00
accessToken: "eyJhbGciOiJIUzUxMiJ9.newAdmin",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.newAdminRefresh",
2022-10-25 17:51:21 +08:00
// `expires`选择这种日期格式是为了方便调试,后端直接设置时间戳或许更方便(每次都应该递增)。如果后端返回的是时间戳格式,前端开发请来到这个目录`src/utils/auth.ts`,把第`38`行的代码换成expires = data.expires即可。
2024-03-09 16:27:52 +08:00
expires: "2030/10/30 23:59:59"
2022-10-25 17:51:21 +08:00
}
};
} else {
return {
success: false,
data: {}
};
}
}
}
2024-03-09 16:27:52 +08:00
]);