2026-03-27 22:20:25 +08:00
|
|
|
import request from "@/utils/request";
|
|
|
|
|
import type { LoginForm, LoginResponse, User } from "@/types/auth";
|
|
|
|
|
|
|
|
|
|
export const authApi = {
|
|
|
|
|
login: async (data: LoginForm): Promise<LoginResponse> => {
|
|
|
|
|
const response = await request.post("/auth/login", data);
|
|
|
|
|
return response as unknown as LoginResponse;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
logout: async (): Promise<void> => {
|
|
|
|
|
await request.post("/auth/logout");
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getUserInfo: async (): Promise<User> => {
|
|
|
|
|
const response = await request.get("/auth/user-info");
|
|
|
|
|
return response as unknown as User;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
refreshToken: async (): Promise<{ token: string }> => {
|
|
|
|
|
const response = await request.post("/auth/refresh-token");
|
|
|
|
|
return response as unknown as { token: string };
|
|
|
|
|
},
|
|
|
|
|
};
|