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 { baseRequestClient, requestClient } from '#/api/request';
|
| export namespace AuthApi {
| /** 登录接口参数 */
| export interface LoginParams {
| password?: string;
| username?: string;
| }
|
| /** 登录接口返回值 */
| export interface LoginResult {
| accessToken: string;
| }
|
| export interface RefreshTokenResult {
| data: string;
| status: number;
| }
| }
|
| /**
| * 登录
| */
| export async function loginApi(data: AuthApi.LoginParams) {
| return requestClient.post<AuthApi.LoginResult>('/auth/login', data, {
| withCredentials: true,
| });
| }
|
| /**
| * 刷新accessToken
| */
| export async function refreshTokenApi() {
| return baseRequestClient.post<AuthApi.RefreshTokenResult>(
| '/auth/refresh',
| null,
| {
| withCredentials: true,
| },
| );
| }
|
| /**
| * 退出登录
| */
| export async function logoutApi() {
| return baseRequestClient.post('/auth/logout', null, {
| withCredentials: true,
| });
| }
|
| /**
| * 获取用户权限码
| */
| export async function getAccessCodesApi() {
| return requestClient.get<string[]>('/auth/codes');
| }
|
|