feat: ✨ 工作台页面和用户分页列表页面完善
This commit is contained in:
47
src/api/auth/index.ts
Normal file
47
src/api/auth/index.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
const AuthAPI = {
|
||||
/**
|
||||
* 登录接口
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @returns 返回 token
|
||||
*/
|
||||
login(data: LoginFormData): Promise<LoginResult> {
|
||||
console.log("data", data);
|
||||
return request<LoginResult>({
|
||||
url: "/api/v1/auth/login",
|
||||
method: "POST",
|
||||
data: data,
|
||||
header: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 登出接口
|
||||
*/
|
||||
logout(): Promise<void> {
|
||||
return request({
|
||||
url: "/api/v1/auth/logout",
|
||||
method: "DELETE",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default AuthAPI;
|
||||
|
||||
/** 登录响应 */
|
||||
export interface LoginResult {
|
||||
/** 访问token */
|
||||
accessToken: string;
|
||||
/** token 类型 */
|
||||
tokenType?: string;
|
||||
}
|
||||
|
||||
export interface LoginFormData {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
Reference in New Issue
Block a user