-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathauth.ts
More file actions
57 lines (48 loc) · 1005 Bytes
/
auth.ts
File metadata and controls
57 lines (48 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import {
authRequestClient,
baseRequestClient,
requestClient,
} from '#/api/request';
export interface CaptchaResult {
image: string;
image_type: string;
}
export interface LoginParams {
username: string;
password: string;
captcha: string;
}
export interface LoginResult {
access_token: string;
}
export type RefreshTokenResult = LoginResult;
/**
* 登录验证码
*/
export async function getCaptchaApi() {
return requestClient.get<CaptchaResult>('/api/v1/auth/captcha');
}
/**
* 登录
*/
export async function loginApi(data: LoginParams) {
return requestClient.post<LoginResult>('/api/v1/auth/login', data);
}
/**
* 刷新accessToken
*/
export async function refreshTokenApi() {
return baseRequestClient.post<RefreshTokenResult>('/api/v1/token/new');
}
/**
* 退出登录
*/
export async function logoutApi() {
return authRequestClient.post('/api/v1/auth/logout');
}
/**
* 获取用户权限码
*/
export async function getAccessCodesApi() {
return [];
}