Skip to content

Commit 88e3c67

Browse files
author
sunshine824
committed
fetch.js优化,更好支持typescript
1 parent 9a43c3b commit 88e3c67

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/api/types/user.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
// 登录参数
2-
export interface ILoginApiParams {
3-
username: string // 用户名
4-
password: string // 密码
5-
captcha: string // 验证码
6-
uuid: string // 验证码uuid
7-
}
8-
1+
/**
2+
* 接口返回结果Types
3+
* --------------------------------------------------------------------------
4+
*/
95
// 登录返回结果
106
export interface ILoginData {
117
token: string
@@ -15,12 +11,26 @@ export interface ILoginData {
1511
}
1612
}
1713

14+
/**
15+
* 接口参数Types
16+
* --------------------------------------------------------------------------
17+
*/
18+
// 登录参数
19+
export interface ILoginApiParams {
20+
username: string // 用户名
21+
password: string // 密码
22+
captcha: string // 验证码
23+
uuid: string // 验证码uuid
24+
}
1825
// 注销登录参数
1926
export interface ILogoutParams {}
20-
2127
// 获取用户权限参数
2228
export interface IPermissionsParams {}
2329

30+
/**
31+
* 接口定义Types
32+
* --------------------------------------------------------------------------
33+
*/
2434
export interface IUserApi {
2535
login: (params: ILoginApiParams) => Promise<StoreState.ResType<ILoginData>>
2636
logout: (params: ILogoutParams) => Promise<StoreState.ResType<any>>

src/types/interfaces.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ declare namespace StoreState {
99
// 接口返回结构
1010
export interface ResType<T> {
1111
code: number
12-
data?: T
12+
data: T
1313
msg?: string
1414
status: boolean
1515
}

0 commit comments

Comments
 (0)