@wzyjs/utils 0.0.30 → 0.1.0
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/{browser/cjs/utils/src → cjs}/browser/element.d.ts +9 -9
- package/dist/cjs/browser/element.js +59 -0
- package/dist/{node/cjs/utils/src → cjs}/browser/index.d.ts +18 -18
- package/dist/cjs/browser/index.js +64 -0
- package/dist/{browser/cjs/utils/src → cjs}/browser/other.d.ts +1 -1
- package/dist/cjs/browser/other.js +35 -0
- package/dist/{browser/esm/utils/src → cjs}/browser/style.d.ts +10 -10
- package/dist/cjs/browser/style.js +81 -0
- package/dist/{browser/cjs/utils/src → cjs}/browser.d.ts +2 -2
- package/dist/cjs/browser.js +25 -0
- package/dist/{browser/esm/utils/src → cjs}/common/classs.d.ts +5 -5
- package/dist/cjs/common/classs.js +36 -0
- package/dist/{browser/cjs/utils/src → cjs}/common/dayjs.d.ts +4 -4
- package/dist/cjs/common/dayjs.js +57 -0
- package/dist/{node/cjs/utils/src → cjs}/common/index.d.ts +11 -11
- package/dist/cjs/common/index.js +99 -0
- package/dist/{browser/cjs/utils/src → cjs}/common/number.d.ts +3 -3
- package/dist/cjs/common/number.js +55 -0
- package/dist/{browser/esm/utils/src → cjs}/common/object.d.ts +10 -10
- package/dist/cjs/common/object.js +65 -0
- package/dist/{node/esm/utils/src → cjs}/common/other.d.ts +26 -26
- package/dist/cjs/common/other.js +129 -0
- package/dist/{browser/cjs/utils/src → cjs}/common/string.d.ts +16 -16
- package/dist/cjs/common/string.js +157 -0
- package/dist/{node/cjs/utils/src → cjs}/node/database/Collection.d.ts +22 -22
- package/dist/cjs/node/database/Collection.js +219 -0
- package/dist/{node/cjs/utils/src → cjs}/node/database/Database.d.ts +10 -10
- package/dist/cjs/node/database/Database.js +47 -0
- package/dist/{browser/esm/utils/src → cjs}/node/database/index.d.ts +2 -2
- package/dist/cjs/node/database/index.js +38 -0
- package/dist/{node/esm/utils/src → cjs}/node/database/types.d.ts +151 -151
- package/dist/cjs/node/database/types.js +51 -0
- package/dist/{browser/cjs/utils/src → cjs}/node/database/utils.d.ts +3 -3
- package/dist/cjs/node/database/utils.js +53 -0
- package/dist/{browser/cjs/utils/src → cjs}/node/index.d.ts +3 -3
- package/dist/cjs/node/index.js +27 -0
- package/dist/{node/cjs/utils/src → cjs}/node/jsonFile/index.d.ts +6 -6
- package/dist/cjs/node/jsonFile/index.js +51 -0
- package/dist/{browser/cjs/utils/src → cjs}/node/mail/index.d.ts +1 -1
- package/dist/cjs/node/mail/index.js +67 -0
- package/dist/{node/cjs/utils/src → cjs}/node.d.ts +2 -2
- package/dist/cjs/node.js +25 -0
- package/dist/{node/cjs/utils/src → esm}/browser/element.d.ts +9 -9
- package/dist/esm/browser/element.js +43 -0
- package/dist/{node/esm/utils/src → esm}/browser/index.d.ts +18 -18
- package/dist/esm/browser/index.js +15 -0
- package/dist/{node/cjs/utils/src → esm}/browser/other.d.ts +1 -1
- package/dist/esm/browser/other.js +28 -0
- package/dist/{browser/cjs/utils/src → esm}/browser/style.d.ts +10 -10
- package/dist/esm/browser/style.js +55 -0
- package/dist/{node/cjs/utils/src → esm}/browser.d.ts +2 -2
- package/dist/esm/browser.js +2 -0
- package/dist/{browser/cjs/utils/src → esm}/common/classs.d.ts +5 -5
- package/dist/esm/common/classs.js +33 -0
- package/dist/{browser/esm/utils/src → esm}/common/dayjs.d.ts +4 -4
- package/dist/{browser/esm → esm}/common/dayjs.js +10 -10
- package/dist/{node/esm/utils/src → esm}/common/index.d.ts +11 -11
- package/dist/{browser/cjs/utils/src/common/index.d.ts → esm/common/index.js} +12 -11
- package/dist/{browser/esm/utils/src → esm}/common/number.d.ts +3 -3
- package/dist/esm/common/number.js +31 -0
- package/dist/{node/cjs/utils/src → esm}/common/object.d.ts +10 -10
- package/dist/esm/common/object.js +84 -0
- package/dist/{browser/esm/utils/src → esm}/common/other.d.ts +26 -26
- package/dist/esm/common/other.js +173 -0
- package/dist/{browser/esm/utils/src → esm}/common/string.d.ts +16 -16
- package/dist/esm/common/string.js +140 -0
- package/dist/{browser/cjs/utils/src → esm}/node/database/Collection.d.ts +22 -22
- package/dist/esm/node/database/Collection.js +356 -0
- package/dist/{browser/cjs/utils/src → esm}/node/database/Database.d.ts +10 -10
- package/dist/esm/node/database/Database.js +36 -0
- package/dist/{node/cjs/utils/src → esm}/node/database/index.d.ts +2 -2
- package/dist/{browser/cjs/utils/src/node/database/index.d.ts → esm/node/database/index.js} +2 -2
- package/dist/{node/cjs/utils/src → esm}/node/database/types.d.ts +151 -151
- package/dist/esm/node/database/types.js +55 -0
- package/dist/{browser/esm/utils/src → esm}/node/database/utils.d.ts +3 -3
- package/dist/esm/node/database/utils.js +29 -0
- package/dist/{browser/esm/utils/src → esm}/node/index.d.ts +3 -3
- package/dist/esm/node/index.js +3 -0
- package/dist/{browser/cjs/utils/src → esm}/node/jsonFile/index.d.ts +6 -6
- package/dist/esm/node/jsonFile/index.js +43 -0
- package/dist/{browser/esm/utils/src → esm}/node/mail/index.d.ts +1 -1
- package/dist/esm/node/mail/index.js +48 -0
- package/dist/{browser/cjs/utils/src → esm}/node.d.ts +2 -2
- package/dist/esm/node.js +2 -0
- package/package.json +10 -23
- package/dist/browser/cjs/browser/element.js +0 -40
- package/dist/browser/cjs/browser/index.js +0 -20
- package/dist/browser/cjs/browser/other.js +0 -12
- package/dist/browser/cjs/browser/style.js +0 -49
- package/dist/browser/cjs/browser.js +0 -171
- package/dist/browser/cjs/common/classs.js +0 -14
- package/dist/browser/cjs/common/dayjs.js +0 -27
- package/dist/browser/cjs/common/number.js +0 -34
- package/dist/browser/cjs/common/object.js +0 -43
- package/dist/browser/cjs/common/other.js +0 -112
- package/dist/browser/cjs/common/string.js +0 -137
- package/dist/browser/cjs/types/index.d.ts +0 -27
- package/dist/browser/cjs/utils/src/browser/index.d.ts +0 -18
- package/dist/browser/cjs/utils/src/common/object.d.ts +0 -10
- package/dist/browser/cjs/utils/src/common/other.d.ts +0 -26
- package/dist/browser/cjs/utils/src/node/database/types.d.ts +0 -151
- package/dist/browser/esm/browser/element.js +0 -36
- package/dist/browser/esm/browser/index.js +0 -14
- package/dist/browser/esm/browser/other.js +0 -10
- package/dist/browser/esm/browser/style.js +0 -45
- package/dist/browser/esm/browser.js +0 -19
- package/dist/browser/esm/common/classs.js +0 -12
- package/dist/browser/esm/common/number.js +0 -30
- package/dist/browser/esm/common/object.js +0 -39
- package/dist/browser/esm/common/other.js +0 -106
- package/dist/browser/esm/common/string.js +0 -120
- package/dist/browser/esm/types/index.d.ts +0 -27
- package/dist/browser/esm/utils/src/browser/element.d.ts +0 -9
- package/dist/browser/esm/utils/src/browser/index.d.ts +0 -18
- package/dist/browser/esm/utils/src/browser/other.d.ts +0 -1
- package/dist/browser/esm/utils/src/browser.d.ts +0 -2
- package/dist/browser/esm/utils/src/common/index.d.ts +0 -11
- package/dist/browser/esm/utils/src/node/database/Collection.d.ts +0 -22
- package/dist/browser/esm/utils/src/node/database/Database.d.ts +0 -10
- package/dist/browser/esm/utils/src/node/database/types.d.ts +0 -151
- package/dist/browser/esm/utils/src/node/jsonFile/index.d.ts +0 -6
- package/dist/browser/esm/utils/src/node.d.ts +0 -2
- package/dist/node/cjs/common/classs.js +0 -14
- package/dist/node/cjs/common/dayjs.js +0 -27
- package/dist/node/cjs/common/number.js +0 -34
- package/dist/node/cjs/common/object.js +0 -43
- package/dist/node/cjs/common/other.js +0 -112
- package/dist/node/cjs/common/string.js +0 -137
- package/dist/node/cjs/node/database/Collection.js +0 -202
- package/dist/node/cjs/node/database/Database.js +0 -25
- package/dist/node/cjs/node/database/types.js +0 -25
- package/dist/node/cjs/node/database/utils.js +0 -30
- package/dist/node/cjs/node/jsonFile/index.js +0 -29
- package/dist/node/cjs/node/mail/index.js +0 -31
- package/dist/node/cjs/node.js +0 -157
- package/dist/node/cjs/types/index.d.ts +0 -27
- package/dist/node/cjs/utils/src/browser/style.d.ts +0 -10
- package/dist/node/cjs/utils/src/common/classs.d.ts +0 -5
- package/dist/node/cjs/utils/src/common/dayjs.d.ts +0 -4
- package/dist/node/cjs/utils/src/common/number.d.ts +0 -3
- package/dist/node/cjs/utils/src/common/other.d.ts +0 -26
- package/dist/node/cjs/utils/src/common/string.d.ts +0 -16
- package/dist/node/cjs/utils/src/node/database/utils.d.ts +0 -3
- package/dist/node/cjs/utils/src/node/index.d.ts +0 -3
- package/dist/node/cjs/utils/src/node/mail/index.d.ts +0 -1
- package/dist/node/esm/common/classs.js +0 -12
- package/dist/node/esm/common/dayjs.js +0 -18
- package/dist/node/esm/common/number.js +0 -30
- package/dist/node/esm/common/object.js +0 -39
- package/dist/node/esm/common/other.js +0 -106
- package/dist/node/esm/common/string.js +0 -120
- package/dist/node/esm/node/database/Collection.js +0 -200
- package/dist/node/esm/node/database/Database.js +0 -23
- package/dist/node/esm/node/database/types.js +0 -25
- package/dist/node/esm/node/database/utils.js +0 -27
- package/dist/node/esm/node/jsonFile/index.js +0 -27
- package/dist/node/esm/node/mail/index.js +0 -29
- package/dist/node/esm/node.js +0 -14
- package/dist/node/esm/types/index.d.ts +0 -27
- package/dist/node/esm/utils/src/browser/element.d.ts +0 -9
- package/dist/node/esm/utils/src/browser/other.d.ts +0 -1
- package/dist/node/esm/utils/src/browser/style.d.ts +0 -10
- package/dist/node/esm/utils/src/browser.d.ts +0 -2
- package/dist/node/esm/utils/src/common/classs.d.ts +0 -5
- package/dist/node/esm/utils/src/common/dayjs.d.ts +0 -4
- package/dist/node/esm/utils/src/common/number.d.ts +0 -3
- package/dist/node/esm/utils/src/common/object.d.ts +0 -10
- package/dist/node/esm/utils/src/common/string.d.ts +0 -16
- package/dist/node/esm/utils/src/node/database/Collection.d.ts +0 -22
- package/dist/node/esm/utils/src/node/database/Database.d.ts +0 -10
- package/dist/node/esm/utils/src/node/database/index.d.ts +0 -2
- package/dist/node/esm/utils/src/node/database/utils.d.ts +0 -3
- package/dist/node/esm/utils/src/node/index.d.ts +0 -3
- package/dist/node/esm/utils/src/node/jsonFile/index.d.ts +0 -6
- package/dist/node/esm/utils/src/node/mail/index.d.ts +0 -1
- package/dist/node/esm/utils/src/node.d.ts +0 -2
|
@@ -1,10 +1,10 @@
|
|
|
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
|
+
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
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
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/common/object.ts
|
|
20
|
+
var object_exports = {};
|
|
21
|
+
__export(object_exports, {
|
|
22
|
+
filterParams: () => filterParams,
|
|
23
|
+
findItem: () => findItem,
|
|
24
|
+
watch: () => watch
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(object_exports);
|
|
27
|
+
var import_string = require("./string");
|
|
28
|
+
var findItem = (list, attr, value) => {
|
|
29
|
+
return list.find((item) => value === void 0 ? item[attr] : item[attr] === value);
|
|
30
|
+
};
|
|
31
|
+
var filterParams = (params) => {
|
|
32
|
+
return Object.entries(params || {}).reduce((obj, [key, value]) => {
|
|
33
|
+
if (value !== void 0) {
|
|
34
|
+
obj[key] = value;
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}, {});
|
|
38
|
+
};
|
|
39
|
+
var watch = {
|
|
40
|
+
observe(obj, key, watchFun) {
|
|
41
|
+
const val = obj[key];
|
|
42
|
+
Object.defineProperty(obj, key, {
|
|
43
|
+
configurable: true,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
set(value) {
|
|
46
|
+
obj[key] = value;
|
|
47
|
+
watchFun(value, val);
|
|
48
|
+
},
|
|
49
|
+
get() {
|
|
50
|
+
return val;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
setWatcher(data = {}, watch2 = {}) {
|
|
55
|
+
Object.keys(watch2).forEach((v) => {
|
|
56
|
+
this.observe(data, v, watch2[v]);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
filterParams,
|
|
63
|
+
findItem,
|
|
64
|
+
watch
|
|
65
|
+
});
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { KeyValue, OrderParams, Pagination, SortParams } from '@wzyjs/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
|
+
import { KeyValue, OrderParams, Pagination, SortParams } from '@wzyjs/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>;
|
|
@@ -0,0 +1,129 @@
|
|
|
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/common/other.ts
|
|
20
|
+
var other_exports = {};
|
|
21
|
+
__export(other_exports, {
|
|
22
|
+
delay: () => delay,
|
|
23
|
+
executePromise: () => executePromise,
|
|
24
|
+
handleParams: () => handleParams,
|
|
25
|
+
handleRes2List: () => handleRes2List,
|
|
26
|
+
locationFn: () => locationFn
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(other_exports);
|
|
29
|
+
var import_lodash = require("lodash");
|
|
30
|
+
var handleParams = (params, sort) => {
|
|
31
|
+
if (!params) {
|
|
32
|
+
return {
|
|
33
|
+
page: {},
|
|
34
|
+
where: {}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const { current, pageSize, ...other } = params;
|
|
38
|
+
return {
|
|
39
|
+
page: {
|
|
40
|
+
current: current || 1,
|
|
41
|
+
size: pageSize || 10
|
|
42
|
+
},
|
|
43
|
+
where: Object.entries(other).reduce((acc, [key, value]) => {
|
|
44
|
+
if (key && value) {
|
|
45
|
+
acc[key] = typeof value === "string" ? new RegExp(value) : value;
|
|
46
|
+
}
|
|
47
|
+
return acc;
|
|
48
|
+
}, {}),
|
|
49
|
+
order: sort && {
|
|
50
|
+
field: Object.keys(sort)[0],
|
|
51
|
+
type: Object.values(sort)[0] === "ascend" ? "asc" : "desc"
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
var handleRes2List = async (reqPromise) => {
|
|
56
|
+
const { data } = await reqPromise();
|
|
57
|
+
return ((data == null ? void 0 : data.list) || []).map((item) => ({
|
|
58
|
+
label: item.name,
|
|
59
|
+
value: item._id || item.key
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
var executePromise = async (promise) => {
|
|
63
|
+
const start = Date.now();
|
|
64
|
+
const result = await promise;
|
|
65
|
+
const time = Date.now() - start;
|
|
66
|
+
return {
|
|
67
|
+
result,
|
|
68
|
+
time
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
var locationFn = {
|
|
72
|
+
// url地址的query转为query对象
|
|
73
|
+
url2Params: (url = location.href) => {
|
|
74
|
+
url = decodeURIComponent(url);
|
|
75
|
+
let jsonList = {};
|
|
76
|
+
if (url.indexOf("?") > -1) {
|
|
77
|
+
let str = url.slice(url.indexOf("?") + 1);
|
|
78
|
+
let strs = str.split("&");
|
|
79
|
+
for (let i = 0; i < strs.length; i++) {
|
|
80
|
+
jsonList[strs[i].split("=")[0]] = strs[i].split("=")[1];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return jsonList || {};
|
|
84
|
+
},
|
|
85
|
+
// 参数对象转换为url
|
|
86
|
+
params2Url: (params) => {
|
|
87
|
+
let url = "";
|
|
88
|
+
for (let k in params) {
|
|
89
|
+
if (k) {
|
|
90
|
+
url += `${k}=${params[k]}&`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return url.substr(0, url.length - 1);
|
|
94
|
+
},
|
|
95
|
+
// 设置地址栏参数
|
|
96
|
+
setUrlParams: (key, value, keepName) => {
|
|
97
|
+
if (key === void 0 || value === void 0)
|
|
98
|
+
return;
|
|
99
|
+
let allParams = locationFn.url2Params();
|
|
100
|
+
if (keepName) {
|
|
101
|
+
allParams = (0, import_lodash.pick)(allParams, keepName) || {};
|
|
102
|
+
}
|
|
103
|
+
allParams[key] = encodeURIComponent(value);
|
|
104
|
+
const url = location.href;
|
|
105
|
+
const sliceEnd = url.indexOf("?") === -1 ? url.length : url.indexOf("?");
|
|
106
|
+
const domainPath = url.slice(0, sliceEnd);
|
|
107
|
+
const params = locationFn.params2Url(allParams);
|
|
108
|
+
location.replace(`${domainPath}?${params}`);
|
|
109
|
+
},
|
|
110
|
+
// 取地址栏的path部分
|
|
111
|
+
urlGetPath: (url = location.href) => {
|
|
112
|
+
let lastIndex = url.indexOf("?");
|
|
113
|
+
if (lastIndex === -1) {
|
|
114
|
+
lastIndex = url.length;
|
|
115
|
+
}
|
|
116
|
+
return url.slice(0, lastIndex);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var delay = (time = 1e3) => {
|
|
120
|
+
return new Promise((resolve) => setTimeout(resolve, time));
|
|
121
|
+
};
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
delay,
|
|
125
|
+
executePromise,
|
|
126
|
+
handleParams,
|
|
127
|
+
handleRes2List,
|
|
128
|
+
locationFn
|
|
129
|
+
});
|
|
@@ -1,16 +1,16 @@
|
|
|
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;
|
|
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;
|
|
@@ -0,0 +1,157 @@
|
|
|
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/common/string.ts
|
|
20
|
+
var string_exports = {};
|
|
21
|
+
__export(string_exports, {
|
|
22
|
+
amount: () => amount,
|
|
23
|
+
getChinese: () => getChinese,
|
|
24
|
+
getChineseByStr: () => getChineseByStr,
|
|
25
|
+
getCookie: () => getCookie,
|
|
26
|
+
getLength: () => getLength,
|
|
27
|
+
getProxyUrl: () => getProxyUrl,
|
|
28
|
+
getRandomColor: () => getRandomColor,
|
|
29
|
+
getRandomString: () => getRandomString,
|
|
30
|
+
getSliceStr: () => getSliceStr,
|
|
31
|
+
getStrLength: () => getStrLength,
|
|
32
|
+
getType: () => getType,
|
|
33
|
+
isJson: () => isJson,
|
|
34
|
+
jsonParse: () => jsonParse,
|
|
35
|
+
replaceAll: () => replaceAll,
|
|
36
|
+
replaceByRules: () => replaceByRules,
|
|
37
|
+
toString: () => toString
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(string_exports);
|
|
40
|
+
var getChineseByStr = (str) => {
|
|
41
|
+
if (!str) {
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
const match = str.match(/[\u4e00-\u9fa5]/g);
|
|
45
|
+
if (!match) {
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
return match.join("");
|
|
49
|
+
};
|
|
50
|
+
var getStrLength = (value) => {
|
|
51
|
+
if (!value) {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
const chineseLength = getChineseByStr(value).length;
|
|
55
|
+
return value.length - chineseLength + chineseLength * 2;
|
|
56
|
+
};
|
|
57
|
+
var replaceAll = (str, searchValue, replaceValue) => {
|
|
58
|
+
if (!str || !searchValue || !replaceValue) {
|
|
59
|
+
return str || "";
|
|
60
|
+
}
|
|
61
|
+
str = str.replace(searchValue, replaceValue);
|
|
62
|
+
if (!str.includes(searchValue)) {
|
|
63
|
+
return str;
|
|
64
|
+
}
|
|
65
|
+
return replaceAll(str, searchValue, replaceValue);
|
|
66
|
+
};
|
|
67
|
+
var replaceByRules = (str, rules) => {
|
|
68
|
+
rules.forEach(([searchValue, replaceValue]) => {
|
|
69
|
+
str = str.replaceAll(searchValue, replaceValue);
|
|
70
|
+
});
|
|
71
|
+
return str;
|
|
72
|
+
};
|
|
73
|
+
var getType = (value) => {
|
|
74
|
+
return Object.prototype.toString.call(value).slice(8, -1);
|
|
75
|
+
};
|
|
76
|
+
var amount = (str) => {
|
|
77
|
+
const reg = /(?=(?!\b)(\d{3})+$)/g;
|
|
78
|
+
return str.replace(reg, ",");
|
|
79
|
+
};
|
|
80
|
+
var jsonParse = (value) => {
|
|
81
|
+
if (typeof value === "object") {
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
return JSON.parse(value);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var isJson = (str) => {
|
|
91
|
+
try {
|
|
92
|
+
if (getType(JSON.parse(str)) === "Object") {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
} catch (e) {
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
};
|
|
99
|
+
var toString = (value) => {
|
|
100
|
+
return Object.prototype.toString.call(value).slice(8, -1) === "object" ? JSON.stringify(value) : String(value);
|
|
101
|
+
};
|
|
102
|
+
var getRandomColor = () => {
|
|
103
|
+
const color = Math.floor(Math.random() * 16777215).toString(16);
|
|
104
|
+
if (color.length === 6) {
|
|
105
|
+
return color;
|
|
106
|
+
} else {
|
|
107
|
+
return getRandomColor();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var getRandomString = (length = 4) => {
|
|
111
|
+
return Math.random().toString(36).substr(2, length);
|
|
112
|
+
};
|
|
113
|
+
var getChinese = (str) => {
|
|
114
|
+
if (str == null || str === "") {
|
|
115
|
+
return "";
|
|
116
|
+
}
|
|
117
|
+
const res = str.match(/[\u4e00-\u9fa5]/g);
|
|
118
|
+
if (!res) {
|
|
119
|
+
return "";
|
|
120
|
+
}
|
|
121
|
+
return res.join("");
|
|
122
|
+
};
|
|
123
|
+
var getSliceStr = (str, before, after) => {
|
|
124
|
+
return str.slice(str.indexOf(before) + before.length, str.lastIndexOf(after));
|
|
125
|
+
};
|
|
126
|
+
var getProxyUrl = (url) => {
|
|
127
|
+
const beforeUrl = "https://1141871752167714.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/a.LATEST/proxy/?url=";
|
|
128
|
+
return beforeUrl + url;
|
|
129
|
+
};
|
|
130
|
+
var getLength = (value) => {
|
|
131
|
+
const chineseLength = getChinese(value).length;
|
|
132
|
+
return value.length - chineseLength + chineseLength * 2;
|
|
133
|
+
};
|
|
134
|
+
var getCookie = (name) => {
|
|
135
|
+
const reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`);
|
|
136
|
+
const arr = document.cookie.match(reg);
|
|
137
|
+
return arr ? unescape(arr[2]) : null;
|
|
138
|
+
};
|
|
139
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
140
|
+
0 && (module.exports = {
|
|
141
|
+
amount,
|
|
142
|
+
getChinese,
|
|
143
|
+
getChineseByStr,
|
|
144
|
+
getCookie,
|
|
145
|
+
getLength,
|
|
146
|
+
getProxyUrl,
|
|
147
|
+
getRandomColor,
|
|
148
|
+
getRandomString,
|
|
149
|
+
getSliceStr,
|
|
150
|
+
getStrLength,
|
|
151
|
+
getType,
|
|
152
|
+
isJson,
|
|
153
|
+
jsonParse,
|
|
154
|
+
replaceAll,
|
|
155
|
+
replaceByRules,
|
|
156
|
+
toString
|
|
157
|
+
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Database, IKeyValue } from '@cloudbase/node-sdk';
|
|
2
|
-
import { Add, Conditions, Count, Delete, Find, FindList, IdConditions, MethodParams, Update, WhereConditions } from './types';
|
|
3
|
-
export declare class Collection<D extends IKeyValue> {
|
|
4
|
-
private readonly db;
|
|
5
|
-
private readonly collection;
|
|
6
|
-
constructor(db: Database.Db, name: string);
|
|
7
|
-
private joinConditions;
|
|
8
|
-
private request;
|
|
9
|
-
private handleRes;
|
|
10
|
-
private handleData;
|
|
11
|
-
handleConditions(params: MethodParams<D>): MethodParams<D>;
|
|
12
|
-
private exec;
|
|
13
|
-
add(data: Add.Params<D>['data']): Promise<Add.Res>;
|
|
14
|
-
add(data: Add.Params<D>['data'], isReturn: true, conditions?: Pick<IdConditions, 'field'>): Promise<Find.Res<D>>;
|
|
15
|
-
delete(conditions: Conditions): Promise<Delete.Res>;
|
|
16
|
-
update(conditions: Conditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
|
|
17
|
-
update(conditions: IdConditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
|
|
18
|
-
update(conditions: IdConditions, data: Update.Params<D>['data'], isReturn: true, isSet?: true): Promise<Find.Res<D>>;
|
|
19
|
-
find(conditions?: Conditions): Promise<Find.Res<D>>;
|
|
20
|
-
findList(conditions?: WhereConditions): Promise<FindList.Res<D>>;
|
|
21
|
-
count(conditions: Conditions): Promise<Count.Res>;
|
|
22
|
-
}
|
|
1
|
+
import { Database, IKeyValue } from '@cloudbase/node-sdk';
|
|
2
|
+
import { Add, Conditions, Count, Delete, Find, FindList, IdConditions, MethodParams, Update, WhereConditions } from './types';
|
|
3
|
+
export declare class Collection<D extends IKeyValue> {
|
|
4
|
+
private readonly db;
|
|
5
|
+
private readonly collection;
|
|
6
|
+
constructor(db: Database.Db, name: string);
|
|
7
|
+
private joinConditions;
|
|
8
|
+
private request;
|
|
9
|
+
private handleRes;
|
|
10
|
+
private handleData;
|
|
11
|
+
handleConditions(params: MethodParams<D>): MethodParams<D>;
|
|
12
|
+
private exec;
|
|
13
|
+
add(data: Add.Params<D>['data']): Promise<Add.Res>;
|
|
14
|
+
add(data: Add.Params<D>['data'], isReturn: true, conditions?: Pick<IdConditions, 'field'>): Promise<Find.Res<D>>;
|
|
15
|
+
delete(conditions: Conditions): Promise<Delete.Res>;
|
|
16
|
+
update(conditions: Conditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
|
|
17
|
+
update(conditions: IdConditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
|
|
18
|
+
update(conditions: IdConditions, data: Update.Params<D>['data'], isReturn: true, isSet?: true): Promise<Find.Res<D>>;
|
|
19
|
+
find(conditions?: Conditions): Promise<Find.Res<D>>;
|
|
20
|
+
findList(conditions?: WhereConditions): Promise<FindList.Res<D>>;
|
|
21
|
+
count(conditions: Conditions): Promise<Count.Res>;
|
|
22
|
+
}
|