File tree Expand file tree Collapse file tree 1 file changed +38
-14
lines changed Expand file tree Collapse file tree 1 file changed +38
-14
lines changed Original file line number Diff line number Diff line change 1
1
export declare class KsMock {
2
- public option : any ;
3
- constructor ( option : any ) ;
2
+ public option : mock . options ;
3
+ constructor ( option : mock . options ) ;
4
4
public apply ( compiler : any ) : void ;
5
- public server ( option ?: any ) : void ;
5
+ public server ( option ?: mock . options ) : void ;
6
6
}
7
7
export namespace mock {
8
+
8
9
interface anyObject < T = any > {
9
10
[ prop : string ] : T
10
11
}
12
+
13
+ interface api {
14
+ public ?: boolean ;
15
+ relay ?: string | apiFunc ;
16
+ format ?: apiFunc ;
17
+ error ?: apiErrorFunc ;
18
+ post ?: anyObject ;
19
+ get ?: anyObject ;
20
+ [ prop : string ] : any ;
21
+ }
22
+
23
+ interface options {
24
+ // 模拟属性相关的配置
25
+ mockData ?: anyObject < api > ;
26
+ // 服务器请求头设置
27
+ headConfig ?: anyObject | null ;
28
+ // 是否允许跨域 当 headConfig 不为空时, 忽略该项
29
+ crossDomain ?: boolean ;
30
+ // 端口号
31
+ port ?: number ;
32
+ // https证书配置
33
+ https ?: {
34
+ key : string ;
35
+ cert : string ;
36
+ } | undefined ;
37
+ // 路由重写规则, 参考 json-server rewriter
38
+ rules ?: anyObject < string > ;
39
+ // 登录地址, 如果配置了loginUrl, 那么除登录和public属性为true的接口外, 其它接口必须在登录之后才可以正常执行
40
+ loginUrl ?: string ;
41
+ // 退出登录地址
42
+ logoutUrl ?: string ;
43
+ }
44
+
11
45
type apiFunc = (
12
46
method : string ,
13
47
params : anyObject ,
@@ -18,7 +52,7 @@ export namespace mock {
18
52
[ prop : string ] : any ;
19
53
}
20
54
) => void | object ;
21
-
55
+
22
56
type apiErrorFunc = (
23
57
method : string ,
24
58
params : anyObject ,
@@ -29,15 +63,5 @@ export namespace mock {
29
63
[ prop : string ] : any ;
30
64
}
31
65
) => undefined | object | string | Function ;
32
-
33
- interface api {
34
- public ?: boolean ;
35
- relay ?: string | apiFunc ;
36
- format ?: apiFunc ;
37
- error ?: apiErrorFunc ;
38
- post ?: anyObject ;
39
- get ?: anyObject ;
40
- [ prop : string ] : any ;
41
- }
42
66
}
43
67
export default KsMock
You can’t perform that action at this time.
0 commit comments