Files
iot-device-management-frontend/apps/web-antd/src/api/core/auth.ts

101 lines
2.2 KiB
TypeScript
Raw Normal View History

import { baseRequestClient, requestClient } from '#/api/request';
import type { AuthPermissionInfo } from '@vben/types';
export namespace AuthApi {
/** 登录接口参数 */
export interface LoginParams {
password?: string;
username?: string;
captchaVerification?: string;
}
/** 登录接口返回值 */
export interface LoginResult {
accessToken: string;
refreshToken: string;
userId: number;
expiresTime: number;
}
export interface RefreshTokenResult {
data: string;
status: number;
}
/** 租户信息返回值 */
export interface TenantResult {
id: number;
name: string;
}
}
/**
*
*/
2024-08-07 13:42:33 +08:00
export async function loginApi(data: AuthApi.LoginParams) {
return requestClient.post<AuthApi.LoginResult>('/system/auth/login', data);
}
/**
* accessToken
*/
export async function refreshTokenApi() {
// TODO @芋艿refreshToken 传递
return baseRequestClient.post<AuthApi.RefreshTokenResult>('/system/auth/refresh', {
withCredentials: true,
});
}
/**
* 退
*/
export async function logoutApi() {
return baseRequestClient.post('/system/auth/logout', {
withCredentials: true,
});
}
// /**
// * 获取用户权限码
// */
// export async function getAccessCodesApi() {
// return requestClient.get<string[]>('/auth/codes');
// }
/**
*
*/
export function getAuthPermissionInfoApi() {
return requestClient.get<AuthPermissionInfo>(
'/system/auth/get-permission-info',
);
}
/**
*
*/
export function getTenantSimpleList() {
return requestClient.get<AuthApi.TenantResult[]>(
`/system/tenant/simple-list`,
);
}
/**
* 使
*/
export function getTenantByWebsite(website: string) {
// TODO @芋艿:改成 params 传递?
return requestClient.get<AuthApi.TenantResult>(`/system/tenant/get-by-website?website=${website}`);
}
// TODO 芋艿:后续怎么放好。
// // 获取验证图片 以及token
// export async function getCaptcha(data: any) {
// return baseRequestClient.post('/system/captcha/get', data);
// }
//
// // 滑动或者点选验证
// export async function checkCaptcha(data: any) {
// return baseRequestClient.post('/system/captcha/check', data);
// }