@wzyjs/types 0.2.0 → 0.2.2
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/dist/cjs/api.d.ts +33 -0
- package/dist/cjs/api.js +40 -0
- package/{base.ts → dist/cjs/base.d.ts} +2 -5
- package/dist/cjs/base.js +17 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/other.d.ts +6 -0
- package/dist/cjs/other.js +17 -0
- package/dist/esm/api.d.ts +33 -0
- package/dist/esm/api.js +23 -0
- package/dist/esm/base.d.ts +2 -0
- package/dist/esm/base.js +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/other.d.ts +6 -0
- package/dist/esm/other.js +1 -0
- package/package.json +17 -3
- package/api.ts +0 -43
- package/dist/cjs/common/index.d.ts +0 -6
- package/dist/cjs/common/tools/index.d.ts +0 -4
- package/dist/cjs/common/tools/number.d.ts +0 -3
- package/dist/cjs/common/tools/number.js +0 -34
- package/dist/cjs/common/tools/object.d.ts +0 -10
- package/dist/cjs/common/tools/object.js +0 -43
- package/dist/cjs/common/tools/other.d.ts +0 -26
- package/dist/cjs/common/tools/other.js +0 -112
- package/dist/cjs/common/tools/string.d.ts +0 -16
- package/dist/cjs/common/tools/string.js +0 -137
- package/dist/cjs/common/types/index.d.ts +0 -20
- package/dist/cjs/fe/dayjs.d.ts +0 -4
- package/dist/cjs/fe/element.d.ts +0 -9
- package/dist/cjs/fe/index.d.ts +0 -20
- package/dist/cjs/fe/middlewares/error.d.ts +0 -3
- package/dist/cjs/fe/middlewares/index.d.ts +0 -1
- package/dist/cjs/fe/other.d.ts +0 -1
- package/dist/cjs/fe/style.d.ts +0 -10
- package/dist/cjs/index_all.d.ts +0 -3
- package/dist/cjs/index_fe.d.ts +0 -2
- package/dist/cjs/index_rd.d.ts +0 -2
- package/dist/cjs/index_rd.js +0 -141
- package/dist/cjs/rd/database/Collection.d.ts +0 -22
- package/dist/cjs/rd/database/Collection.js +0 -202
- package/dist/cjs/rd/database/Database.d.ts +0 -10
- package/dist/cjs/rd/database/Database.js +0 -25
- package/dist/cjs/rd/database/index.d.ts +0 -2
- package/dist/cjs/rd/database/types.d.ts +0 -151
- package/dist/cjs/rd/database/types.js +0 -25
- package/dist/cjs/rd/database/utils.d.ts +0 -3
- package/dist/cjs/rd/database/utils.js +0 -30
- package/dist/cjs/rd/index.d.ts +0 -3
- package/dist/cjs/rd/jsonFile/index.d.ts +0 -6
- package/dist/cjs/rd/jsonFile/index.js +0 -29
- package/dist/cjs/rd/mail/index.d.ts +0 -1
- package/dist/cjs/rd/mail/index.js +0 -31
- package/dist/cjs/rd/middlewares/index.d.ts +0 -1
- package/dist/cjs/rd/middlewares/logger.d.ts +0 -1
- package/dist/esm/common/index.d.ts +0 -6
- package/dist/esm/common/tools/index.d.ts +0 -4
- package/dist/esm/common/tools/number.d.ts +0 -3
- package/dist/esm/common/tools/number.js +0 -30
- package/dist/esm/common/tools/object.d.ts +0 -10
- package/dist/esm/common/tools/object.js +0 -39
- package/dist/esm/common/tools/other.d.ts +0 -26
- package/dist/esm/common/tools/other.js +0 -106
- package/dist/esm/common/tools/string.d.ts +0 -16
- package/dist/esm/common/tools/string.js +0 -120
- package/dist/esm/common/types/index.d.ts +0 -20
- package/dist/esm/fe/dayjs.d.ts +0 -4
- package/dist/esm/fe/dayjs.js +0 -18
- package/dist/esm/fe/element.d.ts +0 -9
- package/dist/esm/fe/element.js +0 -36
- package/dist/esm/fe/index.d.ts +0 -20
- package/dist/esm/fe/index.js +0 -16
- package/dist/esm/fe/middlewares/error.d.ts +0 -3
- package/dist/esm/fe/middlewares/error.js +0 -22
- package/dist/esm/fe/middlewares/index.d.ts +0 -1
- package/dist/esm/fe/other.d.ts +0 -1
- package/dist/esm/fe/other.js +0 -10
- package/dist/esm/fe/style.d.ts +0 -10
- package/dist/esm/fe/style.js +0 -45
- package/dist/esm/index_all.d.ts +0 -3
- package/dist/esm/index_fe.d.ts +0 -2
- package/dist/esm/index_fe.js +0 -19
- package/dist/esm/index_rd.d.ts +0 -2
- package/dist/esm/rd/database/Collection.d.ts +0 -22
- package/dist/esm/rd/database/Database.d.ts +0 -10
- package/dist/esm/rd/database/index.d.ts +0 -2
- package/dist/esm/rd/database/types.d.ts +0 -151
- package/dist/esm/rd/database/utils.d.ts +0 -3
- package/dist/esm/rd/index.d.ts +0 -3
- package/dist/esm/rd/jsonFile/index.d.ts +0 -6
- package/dist/esm/rd/mail/index.d.ts +0 -1
- package/index.ts +0 -3
- package/other.ts +0 -9
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { KeyValue } from './other';
|
|
2
|
+
export interface RequestRes<D = any> {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
data: D;
|
|
6
|
+
}
|
|
7
|
+
export interface Pagination {
|
|
8
|
+
current?: number;
|
|
9
|
+
pageSize?: number;
|
|
10
|
+
}
|
|
11
|
+
export type Order = {
|
|
12
|
+
[key: string]: 'asc' | 'desc';
|
|
13
|
+
};
|
|
14
|
+
export declare enum OperatorType {
|
|
15
|
+
In = "In",
|
|
16
|
+
Like = "Like",
|
|
17
|
+
Between = "Between",
|
|
18
|
+
Equal = "Equal",
|
|
19
|
+
LessThan = "LessThan",
|
|
20
|
+
MoreThan = "MoreThan",
|
|
21
|
+
LessThanOrEqual = "LessThanOrEqual",
|
|
22
|
+
MoreThanOrEqual = "MoreThanOrEqual",
|
|
23
|
+
IsNull = "IsNull"
|
|
24
|
+
}
|
|
25
|
+
export type WhereItem = {
|
|
26
|
+
_type?: OperatorType;
|
|
27
|
+
_value: any;
|
|
28
|
+
};
|
|
29
|
+
export type Where = KeyValue | {
|
|
30
|
+
[key: string]: WhereItem;
|
|
31
|
+
};
|
|
32
|
+
export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend' | null>;
|
|
33
|
+
export type FilterParams = Record<string, (string | number)[] | null>;
|
package/dist/cjs/api.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/api.ts
|
|
20
|
+
var api_exports = {};
|
|
21
|
+
__export(api_exports, {
|
|
22
|
+
OperatorType: () => OperatorType
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(api_exports);
|
|
25
|
+
var OperatorType = /* @__PURE__ */ ((OperatorType2) => {
|
|
26
|
+
OperatorType2["In"] = "In";
|
|
27
|
+
OperatorType2["Like"] = "Like";
|
|
28
|
+
OperatorType2["Between"] = "Between";
|
|
29
|
+
OperatorType2["Equal"] = "Equal";
|
|
30
|
+
OperatorType2["LessThan"] = "LessThan";
|
|
31
|
+
OperatorType2["MoreThan"] = "MoreThan";
|
|
32
|
+
OperatorType2["LessThanOrEqual"] = "LessThanOrEqual";
|
|
33
|
+
OperatorType2["MoreThanOrEqual"] = "MoreThanOrEqual";
|
|
34
|
+
OperatorType2["IsNull"] = "IsNull";
|
|
35
|
+
return OperatorType2;
|
|
36
|
+
})(OperatorType || {});
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
OperatorType
|
|
40
|
+
});
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
// 将指定类型排除、将指定类型设为可选
|
|
5
|
-
export type Set<T, OmitK extends keyof T = never, OptionalK extends Exclude<keyof T, OmitK> = never> = Optional<Omit<T, OmitK>, OptionalK>
|
|
1
|
+
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
2
|
+
export type Set<T, OmitK extends keyof T = never, OptionalK extends Exclude<keyof T, OmitK> = never> = Optional<Omit<T, OmitK>, OptionalK>;
|
package/dist/cjs/base.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/base.ts
|
|
16
|
+
var base_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(base_exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
__reExport(src_exports, require("./base"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./api"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./other"), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require("./base"),
|
|
25
|
+
...require("./api"),
|
|
26
|
+
...require("./other")
|
|
27
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/other.ts
|
|
16
|
+
var other_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(other_exports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { KeyValue } from './other';
|
|
2
|
+
export interface RequestRes<D = any> {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
data: D;
|
|
6
|
+
}
|
|
7
|
+
export interface Pagination {
|
|
8
|
+
current?: number;
|
|
9
|
+
pageSize?: number;
|
|
10
|
+
}
|
|
11
|
+
export type Order = {
|
|
12
|
+
[key: string]: 'asc' | 'desc';
|
|
13
|
+
};
|
|
14
|
+
export declare enum OperatorType {
|
|
15
|
+
In = "In",
|
|
16
|
+
Like = "Like",
|
|
17
|
+
Between = "Between",
|
|
18
|
+
Equal = "Equal",
|
|
19
|
+
LessThan = "LessThan",
|
|
20
|
+
MoreThan = "MoreThan",
|
|
21
|
+
LessThanOrEqual = "LessThanOrEqual",
|
|
22
|
+
MoreThanOrEqual = "MoreThanOrEqual",
|
|
23
|
+
IsNull = "IsNull"
|
|
24
|
+
}
|
|
25
|
+
export type WhereItem = {
|
|
26
|
+
_type?: OperatorType;
|
|
27
|
+
_value: any;
|
|
28
|
+
};
|
|
29
|
+
export type Where = KeyValue | {
|
|
30
|
+
[key: string]: WhereItem;
|
|
31
|
+
};
|
|
32
|
+
export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend' | null>;
|
|
33
|
+
export type FilterParams = Record<string, (string | number)[] | null>;
|
package/dist/esm/api.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// 接口响应的类型
|
|
2
|
+
|
|
3
|
+
// 分页的类型
|
|
4
|
+
|
|
5
|
+
// 后端排序参数的类型
|
|
6
|
+
|
|
7
|
+
// 后端查询参数的类型
|
|
8
|
+
export var OperatorType = /*#__PURE__*/function (OperatorType) {
|
|
9
|
+
OperatorType["In"] = "In";
|
|
10
|
+
OperatorType["Like"] = "Like";
|
|
11
|
+
OperatorType["Between"] = "Between";
|
|
12
|
+
OperatorType["Equal"] = "Equal";
|
|
13
|
+
OperatorType["LessThan"] = "LessThan";
|
|
14
|
+
OperatorType["MoreThan"] = "MoreThan";
|
|
15
|
+
OperatorType["LessThanOrEqual"] = "LessThanOrEqual";
|
|
16
|
+
OperatorType["MoreThanOrEqual"] = "MoreThanOrEqual";
|
|
17
|
+
OperatorType["IsNull"] = "IsNull";
|
|
18
|
+
return OperatorType;
|
|
19
|
+
}({});
|
|
20
|
+
|
|
21
|
+
// 前端排序参数的类型
|
|
22
|
+
|
|
23
|
+
// 前端查询参数的类型
|
package/dist/esm/base.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/types",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"license": "ISC",
|
|
7
|
-
"
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./dist/esm/index.js",
|
|
9
|
+
"require": "./dist/cjs/index.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "father dev",
|
|
13
|
+
"build": "father build"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
8
18
|
"publishConfig": {
|
|
9
19
|
"access": "public"
|
|
10
20
|
},
|
|
@@ -12,5 +22,9 @@
|
|
|
12
22
|
"type": "git",
|
|
13
23
|
"url": "https://gitee.com/wang-zhenyu/app.git"
|
|
14
24
|
},
|
|
15
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "a9e5d6f01fbca5d85b20855a3359a48ed42b67b5",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"father": "^4.4.5",
|
|
28
|
+
"tslib": "^2.6.3"
|
|
29
|
+
}
|
|
16
30
|
}
|
package/api.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop } from 'lodash';
|
|
2
|
-
export { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop, };
|
|
3
|
-
export * as consola from 'consola';
|
|
4
|
-
export * from './tools';
|
|
5
|
-
export * from './types';
|
|
6
|
-
export { default as _ } from 'lodash';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// 取指定范围内的随机数
|
|
4
|
-
const getRandomNum = (min, max) => {
|
|
5
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
6
|
-
};
|
|
7
|
-
// 指定小数点的位数
|
|
8
|
-
const limitDecimals = (v, num = 2, isForce) => {
|
|
9
|
-
let value = parseFloat(v);
|
|
10
|
-
if (isNaN(value)) {
|
|
11
|
-
if (isForce) {
|
|
12
|
-
value = 0;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return value.toFixed(num).toString();
|
|
19
|
-
};
|
|
20
|
-
// 转换成更易读的尺寸单位
|
|
21
|
-
const getFileSize = (size) => {
|
|
22
|
-
let d = 'G';
|
|
23
|
-
let s = size / 1024 / 1024 / 1024;
|
|
24
|
-
if (s < 1) {
|
|
25
|
-
d = 'M';
|
|
26
|
-
s *= 1024;
|
|
27
|
-
}
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
return `${(s.toFixed(1) / 1).toString()}${d}`;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
exports.getFileSize = getFileSize;
|
|
33
|
-
exports.getRandomNum = getRandomNum;
|
|
34
|
-
exports.limitDecimals = limitDecimals;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const findItem: <I>(list: I[], attr: keyof I, value?: I[keyof I] | undefined) => I | undefined;
|
|
2
|
-
export declare const filterParams: (params: {
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
}) => {};
|
|
5
|
-
export declare const watch: {
|
|
6
|
-
observe(obj: {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}, key: string, watchFun: (value: any, val: any) => undefined): void;
|
|
9
|
-
setWatcher(data?: {}, watch?: {}): void;
|
|
10
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// 判断是否有包含指定属性的对象,第三个参数可以指定具体的值
|
|
4
|
-
const findItem = (list, attr, value) => {
|
|
5
|
-
return list.find((item) => value === undefined ? item[attr] : item[attr] === value);
|
|
6
|
-
};
|
|
7
|
-
// 过滤对象中为undefined的属性
|
|
8
|
-
const filterParams = (params) => {
|
|
9
|
-
return Object.entries(params || {}).reduce((obj, [key, value]) => {
|
|
10
|
-
if (value !== undefined) {
|
|
11
|
-
obj[key] = value;
|
|
12
|
-
}
|
|
13
|
-
return obj;
|
|
14
|
-
}, {});
|
|
15
|
-
};
|
|
16
|
-
// 监听属性
|
|
17
|
-
const watch = {
|
|
18
|
-
observe(obj, key, watchFun) {
|
|
19
|
-
// 给该属性设默认值
|
|
20
|
-
const val = obj[key];
|
|
21
|
-
Object.defineProperty(obj, key, {
|
|
22
|
-
configurable: true,
|
|
23
|
-
enumerable: true,
|
|
24
|
-
set(value) {
|
|
25
|
-
obj[key] = value;
|
|
26
|
-
// 赋值(set)时,调用对应函数
|
|
27
|
-
watchFun(value, val);
|
|
28
|
-
},
|
|
29
|
-
get() {
|
|
30
|
-
return val;
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
setWatcher(data = {}, watch = {}) {
|
|
35
|
-
Object.keys(watch).forEach(v => {
|
|
36
|
-
this.observe(data, v, watch[v]); // 监听data内的v属性,传入watch内对应函数以调用
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.filterParams = filterParams;
|
|
42
|
-
exports.findItem = findItem;
|
|
43
|
-
exports.watch = watch;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { KeyValue, OrderParams, Pagination, SortParams } from '../types';
|
|
2
|
-
export declare const handleParams: (params?: Pagination & KeyValue, sort?: SortParams) => {
|
|
3
|
-
page: {
|
|
4
|
-
size?: number | undefined;
|
|
5
|
-
current?: number | undefined;
|
|
6
|
-
};
|
|
7
|
-
where: KeyValue<string, string | number | boolean | RegExp>;
|
|
8
|
-
order?: OrderParams<string> | undefined;
|
|
9
|
-
};
|
|
10
|
-
export declare const handleRes2List: <D>(reqPromise: any) => Promise<{
|
|
11
|
-
label: string;
|
|
12
|
-
value: string;
|
|
13
|
-
}[]>;
|
|
14
|
-
export declare const executePromise: (promise: Promise<any>) => Promise<{
|
|
15
|
-
result: any;
|
|
16
|
-
time: number;
|
|
17
|
-
}>;
|
|
18
|
-
export declare const locationFn: {
|
|
19
|
-
url2Params: (url?: string) => {};
|
|
20
|
-
params2Url: (params: {
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
}) => string;
|
|
23
|
-
setUrlParams: (key: string, value: any, keepName: string) => void;
|
|
24
|
-
urlGetPath: (url?: string) => string;
|
|
25
|
-
};
|
|
26
|
-
export declare const delay: (time?: number) => Promise<unknown>;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var lodash = require('lodash');
|
|
4
|
-
|
|
5
|
-
// 处理 ProComponents 中 ProTable 参数中的 page 和 where 和 sort
|
|
6
|
-
const handleParams = (params, sort) => {
|
|
7
|
-
if (!params) {
|
|
8
|
-
return {
|
|
9
|
-
page: {},
|
|
10
|
-
where: {},
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
const { current, pageSize, ...other } = params;
|
|
14
|
-
return {
|
|
15
|
-
page: {
|
|
16
|
-
current: current || 1,
|
|
17
|
-
size: pageSize || 10,
|
|
18
|
-
},
|
|
19
|
-
where: Object.entries(other).reduce((acc, [key, value]) => {
|
|
20
|
-
if (key && value) {
|
|
21
|
-
acc[key] = typeof value === 'string' ? new RegExp(value) : value;
|
|
22
|
-
}
|
|
23
|
-
return acc;
|
|
24
|
-
}, {}),
|
|
25
|
-
order: sort && {
|
|
26
|
-
field: Object.keys(sort)[0],
|
|
27
|
-
type: Object.values(sort)[0] === 'ascend' ? 'asc' : 'desc',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
// 将 list 的数据处理为 { label: string, value: string }[]
|
|
32
|
-
const handleRes2List = async (reqPromise) => {
|
|
33
|
-
const { data } = await reqPromise();
|
|
34
|
-
return (data?.list || []).map((item) => ({
|
|
35
|
-
label: item.name,
|
|
36
|
-
value: item._id || item.key,
|
|
37
|
-
}));
|
|
38
|
-
};
|
|
39
|
-
// 计算执行 promise 花费的时间
|
|
40
|
-
const executePromise = async (promise) => {
|
|
41
|
-
const start = Date.now();
|
|
42
|
-
const result = await promise;
|
|
43
|
-
const time = Date.now() - start;
|
|
44
|
-
return {
|
|
45
|
-
result,
|
|
46
|
-
time,
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
// 地址栏方面的操作
|
|
50
|
-
const locationFn = {
|
|
51
|
-
// url地址的query转为query对象
|
|
52
|
-
url2Params: (url = location.href) => {
|
|
53
|
-
url = decodeURIComponent(url);
|
|
54
|
-
let jsonList = {};
|
|
55
|
-
if (url.indexOf('?') > -1) {
|
|
56
|
-
let str = url.slice(url.indexOf('?') + 1);
|
|
57
|
-
let strs = str.split('&');
|
|
58
|
-
for (let i = 0; i < strs.length; i++) {
|
|
59
|
-
jsonList[strs[i].split('=')[0]] = strs[i].split('=')[1]; // 如果出现乱码的话,可以用decodeURI()进行解码
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return jsonList || {};
|
|
63
|
-
},
|
|
64
|
-
// 参数对象转换为url
|
|
65
|
-
params2Url: (params) => {
|
|
66
|
-
let url = '';
|
|
67
|
-
for (let k in params) {
|
|
68
|
-
if (k) {
|
|
69
|
-
url += `${k}=${params[k]}&`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return url.substr(0, url.length - 1);
|
|
73
|
-
},
|
|
74
|
-
// 设置地址栏参数
|
|
75
|
-
setUrlParams: (key, value, keepName) => {
|
|
76
|
-
if (key === undefined || value === undefined)
|
|
77
|
-
return;
|
|
78
|
-
// 给地址栏参数对象添加指定参数
|
|
79
|
-
let allParams = locationFn.url2Params();
|
|
80
|
-
if (keepName) {
|
|
81
|
-
allParams = lodash.pick(allParams, keepName) || {};
|
|
82
|
-
}
|
|
83
|
-
allParams[key] = encodeURIComponent(value);
|
|
84
|
-
// 域名和路径
|
|
85
|
-
const url = location.href;
|
|
86
|
-
const sliceEnd = url.indexOf('?') === -1 ? url.length : url.indexOf('?');
|
|
87
|
-
const domainPath = url.slice(0, sliceEnd);
|
|
88
|
-
// 参数
|
|
89
|
-
const params = locationFn.params2Url(allParams);
|
|
90
|
-
// 修改地址栏url
|
|
91
|
-
location.replace(`${domainPath}?${params}`);
|
|
92
|
-
},
|
|
93
|
-
// 取地址栏的path部分
|
|
94
|
-
urlGetPath: (url = location.href) => {
|
|
95
|
-
// 计算要截取的最后一位
|
|
96
|
-
let lastIndex = url.indexOf('?');
|
|
97
|
-
if (lastIndex === -1) {
|
|
98
|
-
lastIndex = url.length;
|
|
99
|
-
}
|
|
100
|
-
return url.slice(0, lastIndex);
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
// 延迟指定毫秒数
|
|
104
|
-
const delay = (time = 1000) => {
|
|
105
|
-
return new Promise(resolve => setTimeout(resolve, time));
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
exports.delay = delay;
|
|
109
|
-
exports.executePromise = executePromise;
|
|
110
|
-
exports.handleParams = handleParams;
|
|
111
|
-
exports.handleRes2List = handleRes2List;
|
|
112
|
-
exports.locationFn = locationFn;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const getChineseByStr: (str: string) => string;
|
|
2
|
-
export declare const getStrLength: (value: string) => number;
|
|
3
|
-
export declare const replaceAll: (str: string, searchValue: string, replaceValue: string) => string;
|
|
4
|
-
export declare const replaceByRules: (str: string, rules: [string, string][]) => string;
|
|
5
|
-
export declare const getType: (value: any) => string;
|
|
6
|
-
export declare const amount: (str: string) => string;
|
|
7
|
-
export declare const jsonParse: (value: string | object) => object;
|
|
8
|
-
export declare const isJson: (str: string) => boolean;
|
|
9
|
-
export declare const toString: (value: any) => string;
|
|
10
|
-
export declare const getRandomColor: () => string;
|
|
11
|
-
export declare const getRandomString: (length?: number) => string;
|
|
12
|
-
export declare const getChinese: (str: string) => string;
|
|
13
|
-
export declare const getSliceStr: (str: string, before: string, after: string) => string;
|
|
14
|
-
export declare const getProxyUrl: (url: string) => string;
|
|
15
|
-
export declare const getLength: (value: string) => number;
|
|
16
|
-
export declare const getCookie: (name: string) => string | null;
|