Skip to content

Commit c63a67c

Browse files
committed
修改类型文件
1 parent 00194cf commit c63a67c

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

index.d.ts

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,47 @@
11
export declare class KsMock {
2-
public option: any;
3-
constructor(option: any);
2+
public option: mock.options;
3+
constructor(option: mock.options);
44
public apply(compiler: any): void;
5-
public server(option?: any): void;
5+
public server(option?: mock.options): void;
66
}
77
export namespace mock {
8+
89
interface anyObject<T=any> {
910
[prop: string]: T
1011
}
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+
1145
type apiFunc = (
1246
method: string,
1347
params: anyObject,
@@ -18,7 +52,7 @@ export namespace mock {
1852
[prop: string]: any;
1953
}
2054
) => void | object;
21-
55+
2256
type apiErrorFunc = (
2357
method: string,
2458
params: anyObject,
@@ -29,15 +63,5 @@ export namespace mock {
2963
[prop: string]: any;
3064
}
3165
) => 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-
}
4266
}
4367
export default KsMock

0 commit comments

Comments
 (0)