Files
certd/packages/ui/certd-client/src/api/modules/api.user.ts
T

68 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-01-29 13:44:19 +08:00
import { request, requestForMock } from "../service";
import { env } from "/@/utils/util.env";
2023-06-27 09:29:43 +08:00
export interface RegisterReq {
username: string;
password: string;
confirmPassword: string;
}
2023-01-29 13:44:19 +08:00
/**
* @description: Login interface parameters
*/
export interface LoginReq {
username: string;
password: string;
}
export interface UserInfoRes {
id: string | number;
username: string;
nickName: string;
2024-10-30 13:21:28 +08:00
avatar: string;
2024-10-15 12:01:38 +08:00
roleIds: number[];
2023-01-29 13:44:19 +08:00
}
export interface LoginRes {
token: string;
expire: number;
}
2023-06-27 09:29:43 +08:00
export async function register(user: RegisterReq): Promise<UserInfoRes> {
return await request({
url: "/register",
method: "post",
data: user
});
}
2023-01-29 13:44:19 +08:00
export async function login(data: LoginReq): Promise<LoginRes> {
if (env.PM_ENABLED === "false") {
//没有开启权限模块,模拟登录
return await requestForMock({
url: "/login",
method: "post",
data
});
}
//如果开启了登录与权限模块,则真实登录
return await request({
url: "/login",
method: "post",
data
});
}
export async function mine(): Promise<UserInfoRes> {
if (env.PM_ENABLED === "false") {
//没有开启权限模块,模拟登录
return await requestForMock({
url: "/sys/authority/user/mine",
method: "post"
});
}
return await request({
2024-08-14 21:24:12 +08:00
url: "/mine/info",
method: "post"
});
}