@wzyjs/types 0.0.31 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.ts +43 -0
- package/base.ts +5 -0
- package/index.ts +3 -40
- package/other.ts +9 -0
- package/package.json +2 -2
package/api.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { KeyValue } from './other'
|
|
2
|
+
|
|
3
|
+
// 接口响应的类型
|
|
4
|
+
export interface RequestRes<D = any> {
|
|
5
|
+
success: boolean,
|
|
6
|
+
message: string,
|
|
7
|
+
data: D,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// 分页的类型
|
|
11
|
+
export interface Pagination {
|
|
12
|
+
current?: number,
|
|
13
|
+
pageSize?: number,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 后端排序参数的类型
|
|
17
|
+
export type Order = { [key: string]: 'asc' | 'desc' }
|
|
18
|
+
|
|
19
|
+
// 后端查询参数的类型
|
|
20
|
+
export enum OperatorType {
|
|
21
|
+
In = 'In',
|
|
22
|
+
Like = 'Like',
|
|
23
|
+
Between = 'Between',
|
|
24
|
+
Equal = 'Equal',
|
|
25
|
+
LessThan = 'LessThan',
|
|
26
|
+
MoreThan = 'MoreThan',
|
|
27
|
+
LessThanOrEqual = 'LessThanOrEqual',
|
|
28
|
+
MoreThanOrEqual = 'MoreThanOrEqual',
|
|
29
|
+
IsNull = 'IsNull',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type WhereItem = {
|
|
33
|
+
_type?: OperatorType;
|
|
34
|
+
_value: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type Where = KeyValue | { [key: string]: WhereItem }
|
|
38
|
+
|
|
39
|
+
// 前端排序参数的类型
|
|
40
|
+
export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend' | null>
|
|
41
|
+
|
|
42
|
+
// 前端查询参数的类型
|
|
43
|
+
export type FilterParams = Record<string, (string | number)[] | null>
|
package/base.ts
ADDED
package/index.ts
CHANGED
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
message: string,
|
|
5
|
-
data: D,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// 键值对的类型
|
|
9
|
-
export type KeyValue<D extends object | string = string, V = any> = Partial<Record<D extends string ? string : keyof D, V>>
|
|
10
|
-
|
|
11
|
-
// 分页的类型
|
|
12
|
-
export interface Pagination {
|
|
13
|
-
current?: number,
|
|
14
|
-
pageSize?: number,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// 前端排序参数的类型
|
|
18
|
-
export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend'>
|
|
19
|
-
|
|
20
|
-
// 后端排序参数的类型
|
|
21
|
-
export type OrderParams<D extends object | string = string> = {
|
|
22
|
-
field: D extends string ? string : keyof D,
|
|
23
|
-
type: 'asc' | 'desc'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 选项
|
|
27
|
-
export interface Option<V extends string | number = string> {
|
|
28
|
-
label: string,
|
|
29
|
-
value: V,
|
|
30
|
-
children?: Option<V>[],
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// 排序参数的类型
|
|
34
|
-
export type OrderBy = { [key: string]: 'asc' | 'desc' } | { [key: string]: 'asc' | 'desc' }[]
|
|
35
|
-
|
|
36
|
-
// 将指定 key 设为可选
|
|
37
|
-
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
|
|
38
|
-
|
|
39
|
-
// 将指定类型排除、将指定类型设为可选
|
|
40
|
-
export type Set<T, OmitK extends keyof T = never, OptionalK extends Exclude<keyof T, OmitK> = never> = Optional<Omit<T, OmitK>, OptionalK>
|
|
1
|
+
export * from './base'
|
|
2
|
+
export * from './api'
|
|
3
|
+
export * from './other'
|
package/other.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 键值对
|
|
2
|
+
export type KeyValue<D extends object | string = string, V = any> = Partial<Record<D extends string ? string : keyof D, V>>
|
|
3
|
+
|
|
4
|
+
// 选项
|
|
5
|
+
export interface Option<V extends string | number = string> {
|
|
6
|
+
label: string,
|
|
7
|
+
value: V,
|
|
8
|
+
children?: Option<V>[],
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"license": "ISC",
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "https://gitee.com/wang-zhenyu/app.git"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "efe38482405854e23ae84434e0ed974afe798b03"
|
|
16
16
|
}
|