24 lines
696 B
TypeScript
24 lines
696 B
TypeScript
|
|
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 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 User;
|
||
|
|
},
|
||
|
|
|
||
|
|
refreshToken: async (): Promise<{ token: string }> => {
|
||
|
|
const response = await request.post("/auth/refresh-token");
|
||
|
|
return response as { token: string };
|
||
|
|
},
|
||
|
|
};
|