@wzyjs/utils 0.2.36 → 0.2.37
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/ai/302/axios.d.ts +2 -0
- package/dist/ai/302/chat/index.d.ts +1 -0
- package/dist/ai/302/image/index.d.ts +1 -0
- package/dist/ai/302/image/midjourney.d.ts +2 -0
- package/dist/ai/302/index.d.ts +2 -0
- package/dist/ai/index.d.ts +3 -0
- package/dist/ai/keling/axios.d.ts +2 -0
- package/dist/ai/keling/index.d.ts +8 -0
- package/dist/ai/keling/utils.d.ts +4 -0
- package/dist/ai/midjourney/index.d.ts +1 -0
- package/dist/ai/midjourney/utils.d.ts +12 -0
- package/dist/browser/download.d.ts +1 -0
- package/dist/browser/element.d.ts +6 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/other.d.ts +2 -0
- package/dist/browser/style.d.ts +10 -0
- package/dist/browser.cjs.js +21010 -0
- package/dist/browser.esm.js +21007 -0
- package/dist/common/antd.d.ts +11 -0
- package/dist/common/array.d.ts +3 -0
- package/dist/common/image.d.ts +1 -0
- package/dist/common/index.d.ts +13 -0
- package/dist/common/location.d.ts +8 -0
- package/dist/common/number.d.ts +5 -0
- package/dist/common/object.d.ts +10 -0
- package/dist/common/other.d.ts +4 -0
- package/dist/common/promise.d.ts +5 -0
- package/dist/common/string.d.ts +22 -0
- package/dist/node/file/index.d.ts +2 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/mail/index.d.ts +1 -0
- package/dist/node/oss/index.d.ts +9 -0
- package/dist/node.cjs.js +97007 -0
- package/dist/{cjs/node.d.ts → node.d.ts} +1 -0
- package/dist/node.esm.js +96989 -0
- package/package.json +27 -25
- package/dist/cjs/browser/element.js +0 -59
- package/dist/cjs/browser/index.js +0 -66
- package/dist/cjs/browser/initHttpClient.js +0 -62
- package/dist/cjs/browser/other.js +0 -35
- package/dist/cjs/browser/style.js +0 -81
- package/dist/cjs/browser.js +0 -25
- package/dist/cjs/common/array.js +0 -68
- package/dist/cjs/common/classs.js +0 -36
- package/dist/cjs/common/dayjs.js +0 -70
- package/dist/cjs/common/index.d.ts +0 -13
- package/dist/cjs/common/index.js +0 -106
- package/dist/cjs/common/number.js +0 -69
- package/dist/cjs/common/object.js +0 -65
- package/dist/cjs/common/other.js +0 -129
- package/dist/cjs/common/string.js +0 -190
- package/dist/cjs/node/file/index.js +0 -58
- package/dist/cjs/node/index.js +0 -48
- package/dist/cjs/node/jsonFile/index.js +0 -75
- package/dist/cjs/node/mail/index.js +0 -67
- package/dist/cjs/node.js +0 -25
- package/dist/esm/browser/element.js +0 -43
- package/dist/esm/browser/index.js +0 -16
- package/dist/esm/browser/initHttpClient.js +0 -67
- package/dist/esm/browser/other.js +0 -28
- package/dist/esm/browser/style.js +0 -55
- package/dist/esm/browser.d.ts +0 -2
- package/dist/esm/browser.js +0 -2
- package/dist/esm/common/array.js +0 -65
- package/dist/esm/common/classs.js +0 -33
- package/dist/esm/common/dayjs.d.ts +0 -19
- package/dist/esm/common/dayjs.js +0 -29
- package/dist/esm/common/index.d.ts +0 -13
- package/dist/esm/common/index.js +0 -14
- package/dist/esm/common/number.js +0 -52
- package/dist/esm/common/object.js +0 -84
- package/dist/esm/common/other.js +0 -167
- package/dist/esm/common/string.js +0 -180
- package/dist/esm/node/file/index.js +0 -52
- package/dist/esm/node/index.js +0 -4
- package/dist/esm/node/jsonFile/index.js +0 -101
- package/dist/esm/node/mail/index.js +0 -48
- package/dist/esm/node.d.ts +0 -2
- package/dist/esm/node.js +0 -2
- /package/dist/{cjs/browser.d.ts → browser.d.ts} +0 -0
- /package/dist/{cjs/common → common}/dayjs.d.ts +0 -0
package/dist/cjs/common/index.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/common/index.ts
|
|
31
|
-
var common_exports = {};
|
|
32
|
-
__export(common_exports, {
|
|
33
|
-
Dayjs: () => import_dayjs.Dayjs,
|
|
34
|
-
Timezone: () => import_dayjs.Timezone,
|
|
35
|
-
_: () => import_lodash2.default,
|
|
36
|
-
axios: () => import_axios.default,
|
|
37
|
-
cloneDeep: () => import_lodash.cloneDeep,
|
|
38
|
-
consola: () => consola,
|
|
39
|
-
dayjs: () => import_dayjs.default,
|
|
40
|
-
debounce: () => import_lodash.debounce,
|
|
41
|
-
find: () => import_lodash.find,
|
|
42
|
-
groupBy: () => import_lodash.groupBy,
|
|
43
|
-
isBoolean: () => import_lodash.isBoolean,
|
|
44
|
-
isEmpty: () => import_lodash.isEmpty,
|
|
45
|
-
isEqual: () => import_lodash.isEqual,
|
|
46
|
-
isError: () => import_lodash.isError,
|
|
47
|
-
isFunction: () => import_lodash.isFunction,
|
|
48
|
-
isNumber: () => import_lodash.isNumber,
|
|
49
|
-
isObject: () => import_lodash.isObject,
|
|
50
|
-
isString: () => import_lodash.isString,
|
|
51
|
-
merge: () => import_lodash.merge,
|
|
52
|
-
noop: () => import_lodash.noop,
|
|
53
|
-
omit: () => import_lodash.omit,
|
|
54
|
-
pick: () => import_lodash.pick,
|
|
55
|
-
uniq: () => import_lodash.uniq,
|
|
56
|
-
uniqBy: () => import_lodash.uniqBy,
|
|
57
|
-
uniqWith: () => import_lodash.uniqWith
|
|
58
|
-
});
|
|
59
|
-
module.exports = __toCommonJS(common_exports);
|
|
60
|
-
var import_lodash = require("lodash");
|
|
61
|
-
var consola = __toESM(require("consola"));
|
|
62
|
-
var import_dayjs = __toESM(require("./dayjs"));
|
|
63
|
-
__reExport(common_exports, require("zod"), module.exports);
|
|
64
|
-
__reExport(common_exports, require("./string"), module.exports);
|
|
65
|
-
__reExport(common_exports, require("./object"), module.exports);
|
|
66
|
-
__reExport(common_exports, require("./other"), module.exports);
|
|
67
|
-
__reExport(common_exports, require("./number"), module.exports);
|
|
68
|
-
__reExport(common_exports, require("./classs"), module.exports);
|
|
69
|
-
__reExport(common_exports, require("./array"), module.exports);
|
|
70
|
-
var import_lodash2 = __toESM(require("lodash"));
|
|
71
|
-
var import_axios = __toESM(require("axios"));
|
|
72
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
-
0 && (module.exports = {
|
|
74
|
-
Dayjs,
|
|
75
|
-
Timezone,
|
|
76
|
-
_,
|
|
77
|
-
axios,
|
|
78
|
-
cloneDeep,
|
|
79
|
-
consola,
|
|
80
|
-
dayjs,
|
|
81
|
-
debounce,
|
|
82
|
-
find,
|
|
83
|
-
groupBy,
|
|
84
|
-
isBoolean,
|
|
85
|
-
isEmpty,
|
|
86
|
-
isEqual,
|
|
87
|
-
isError,
|
|
88
|
-
isFunction,
|
|
89
|
-
isNumber,
|
|
90
|
-
isObject,
|
|
91
|
-
isString,
|
|
92
|
-
merge,
|
|
93
|
-
noop,
|
|
94
|
-
omit,
|
|
95
|
-
pick,
|
|
96
|
-
uniq,
|
|
97
|
-
uniqBy,
|
|
98
|
-
uniqWith,
|
|
99
|
-
...require("zod"),
|
|
100
|
-
...require("./string"),
|
|
101
|
-
...require("./object"),
|
|
102
|
-
...require("./other"),
|
|
103
|
-
...require("./number"),
|
|
104
|
-
...require("./classs"),
|
|
105
|
-
...require("./array")
|
|
106
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
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/number.ts
|
|
20
|
-
var number_exports = {};
|
|
21
|
-
__export(number_exports, {
|
|
22
|
-
getFileSize: () => getFileSize,
|
|
23
|
-
getRandomNum: () => getRandomNum,
|
|
24
|
-
isValidNumber: () => isValidNumber,
|
|
25
|
-
limitDecimals: () => limitDecimals
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(number_exports);
|
|
28
|
-
var getRandomNum = (min, max) => {
|
|
29
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
30
|
-
};
|
|
31
|
-
var limitDecimals = (v, num = 2, isForce) => {
|
|
32
|
-
let value = parseFloat(v);
|
|
33
|
-
if (isNaN(value)) {
|
|
34
|
-
if (isForce) {
|
|
35
|
-
value = 0;
|
|
36
|
-
} else {
|
|
37
|
-
return "";
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return value.toFixed(num).toString();
|
|
41
|
-
};
|
|
42
|
-
var getFileSize = (size) => {
|
|
43
|
-
let d = "G";
|
|
44
|
-
let s = size / 1024 / 1024 / 1024;
|
|
45
|
-
if (s < 1) {
|
|
46
|
-
d = "M";
|
|
47
|
-
s *= 1024;
|
|
48
|
-
}
|
|
49
|
-
return `${(s.toFixed(1) / 1).toString()}${d}`;
|
|
50
|
-
};
|
|
51
|
-
var isValidNumber = (value) => {
|
|
52
|
-
if (typeof value !== "number") {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
if (isNaN(value)) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
if (value === Infinity || value === -Infinity) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
};
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
getFileSize,
|
|
66
|
-
getRandomNum,
|
|
67
|
-
isValidNumber,
|
|
68
|
-
limitDecimals
|
|
69
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
});
|
package/dist/cjs/common/other.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
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, filter, additional) => {
|
|
31
|
-
const { current = 1, pageSize = 10, ...where } = params || {};
|
|
32
|
-
const where_ = {
|
|
33
|
-
...additional || {},
|
|
34
|
-
...where || {},
|
|
35
|
-
...filter || {}
|
|
36
|
-
};
|
|
37
|
-
const order_ = Object.keys(sort).reduce((acc, key) => {
|
|
38
|
-
const value = sort[key];
|
|
39
|
-
if (value === "ascend") {
|
|
40
|
-
acc[key] = "asc";
|
|
41
|
-
} else if (value === "descend") {
|
|
42
|
-
acc[key] = "desc";
|
|
43
|
-
}
|
|
44
|
-
return acc;
|
|
45
|
-
}, {});
|
|
46
|
-
return {
|
|
47
|
-
where: Object.keys(where_).length ? where_ : void 0,
|
|
48
|
-
order: Object.keys(order_).length ? order_ : void 0,
|
|
49
|
-
pagination: {
|
|
50
|
-
current,
|
|
51
|
-
pageSize
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
var handleRes2List = async (reqPromise) => {
|
|
56
|
-
const { data } = await reqPromise();
|
|
57
|
-
return ((data == null ? void 0 : data.data) || []).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,190 +0,0 @@
|
|
|
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
|
-
generateAlphabetArray: () => generateAlphabetArray,
|
|
24
|
-
getChinese: () => getChinese,
|
|
25
|
-
getChineseByStr: () => getChineseByStr,
|
|
26
|
-
getCookie: () => getCookie,
|
|
27
|
-
getLength: () => getLength,
|
|
28
|
-
getProxyUrl: () => getProxyUrl,
|
|
29
|
-
getRandomColor: () => getRandomColor,
|
|
30
|
-
getRandomString: () => getRandomString,
|
|
31
|
-
getSliceStr: () => getSliceStr,
|
|
32
|
-
getStrLength: () => getStrLength,
|
|
33
|
-
getType: () => getType,
|
|
34
|
-
isJson: () => isJson,
|
|
35
|
-
jsonParse: () => jsonParse,
|
|
36
|
-
levenshteinDistance: () => levenshteinDistance,
|
|
37
|
-
replaceAll: () => replaceAll,
|
|
38
|
-
replaceByRules: () => replaceByRules,
|
|
39
|
-
toString: () => toString
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(string_exports);
|
|
42
|
-
var getChineseByStr = (str) => {
|
|
43
|
-
if (!str) {
|
|
44
|
-
return "";
|
|
45
|
-
}
|
|
46
|
-
const match = str.match(/[\u4e00-\u9fa5]/g);
|
|
47
|
-
if (!match) {
|
|
48
|
-
return "";
|
|
49
|
-
}
|
|
50
|
-
return match.join("");
|
|
51
|
-
};
|
|
52
|
-
var getStrLength = (value) => {
|
|
53
|
-
if (!value) {
|
|
54
|
-
return 0;
|
|
55
|
-
}
|
|
56
|
-
const chineseLength = getChineseByStr(value).length;
|
|
57
|
-
return value.length - chineseLength + chineseLength * 2;
|
|
58
|
-
};
|
|
59
|
-
var replaceAll = (str, searchValue, replaceValue) => {
|
|
60
|
-
if (!str || !searchValue || !replaceValue) {
|
|
61
|
-
return str || "";
|
|
62
|
-
}
|
|
63
|
-
str = str.replace(searchValue, replaceValue);
|
|
64
|
-
if (!str.includes(searchValue)) {
|
|
65
|
-
return str;
|
|
66
|
-
}
|
|
67
|
-
return replaceAll(str, searchValue, replaceValue);
|
|
68
|
-
};
|
|
69
|
-
var replaceByRules = (str, rules) => {
|
|
70
|
-
rules.forEach(([searchValue, replaceValue]) => {
|
|
71
|
-
str = str.replaceAll(searchValue, replaceValue);
|
|
72
|
-
});
|
|
73
|
-
return str;
|
|
74
|
-
};
|
|
75
|
-
var getType = (value) => {
|
|
76
|
-
return Object.prototype.toString.call(value).slice(8, -1);
|
|
77
|
-
};
|
|
78
|
-
var amount = (str) => {
|
|
79
|
-
const reg = /(?=(?!\b)(\d{3})+$)/g;
|
|
80
|
-
return str.replace(reg, ",");
|
|
81
|
-
};
|
|
82
|
-
var jsonParse = (value) => {
|
|
83
|
-
if (typeof value === "object") {
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
return JSON.parse(value);
|
|
88
|
-
} catch (err) {
|
|
89
|
-
return {};
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
var isJson = (str) => {
|
|
93
|
-
try {
|
|
94
|
-
if (getType(JSON.parse(str)) === "Object") {
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
} catch (e) {
|
|
98
|
-
}
|
|
99
|
-
return false;
|
|
100
|
-
};
|
|
101
|
-
var toString = (value) => {
|
|
102
|
-
return Object.prototype.toString.call(value).slice(8, -1) === "object" ? JSON.stringify(value) : String(value);
|
|
103
|
-
};
|
|
104
|
-
var getRandomColor = () => {
|
|
105
|
-
const color = Math.floor(Math.random() * 16777215).toString(16);
|
|
106
|
-
if (color.length === 6) {
|
|
107
|
-
return color;
|
|
108
|
-
} else {
|
|
109
|
-
return getRandomColor();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
var getRandomString = (length = 4) => {
|
|
113
|
-
return Math.random().toString(36).substr(2, length);
|
|
114
|
-
};
|
|
115
|
-
var getChinese = (str) => {
|
|
116
|
-
if (str == null || str === "") {
|
|
117
|
-
return "";
|
|
118
|
-
}
|
|
119
|
-
const res = str.match(/[\u4e00-\u9fa5]/g);
|
|
120
|
-
if (!res) {
|
|
121
|
-
return "";
|
|
122
|
-
}
|
|
123
|
-
return res.join("");
|
|
124
|
-
};
|
|
125
|
-
var getSliceStr = (str, before, after) => {
|
|
126
|
-
return str.slice(str.indexOf(before) + before.length, str.lastIndexOf(after));
|
|
127
|
-
};
|
|
128
|
-
var getProxyUrl = (url) => {
|
|
129
|
-
const beforeUrl = "https://1141871752167714.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/a.LATEST/proxy/?url=";
|
|
130
|
-
return beforeUrl + url;
|
|
131
|
-
};
|
|
132
|
-
var getLength = (value) => {
|
|
133
|
-
const chineseLength = getChinese(value).length;
|
|
134
|
-
return value.length - chineseLength + chineseLength * 2;
|
|
135
|
-
};
|
|
136
|
-
var getCookie = (name) => {
|
|
137
|
-
const reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`);
|
|
138
|
-
const arr = document.cookie.match(reg);
|
|
139
|
-
return arr ? unescape(arr[2]) : null;
|
|
140
|
-
};
|
|
141
|
-
var generateAlphabetArray = (n) => {
|
|
142
|
-
return Array.from({ length: n }, (_, i) => String.fromCharCode(97 + i));
|
|
143
|
-
};
|
|
144
|
-
var levenshteinDistance = (a, b) => {
|
|
145
|
-
const matrix = [];
|
|
146
|
-
for (let i = 0; i <= b.length; i++) {
|
|
147
|
-
matrix[i] = [i];
|
|
148
|
-
}
|
|
149
|
-
for (let j = 0; j <= a.length; j++) {
|
|
150
|
-
matrix[0][j] = j;
|
|
151
|
-
}
|
|
152
|
-
for (let i = 1; i <= b.length; i++) {
|
|
153
|
-
for (let j = 1; j <= a.length; j++) {
|
|
154
|
-
if (b[i - 1] === a[j - 1]) {
|
|
155
|
-
matrix[i][j] = matrix[i - 1][j - 1];
|
|
156
|
-
} else {
|
|
157
|
-
matrix[i][j] = Math.min(
|
|
158
|
-
matrix[i - 1][j - 1] + 1,
|
|
159
|
-
// 替换
|
|
160
|
-
matrix[i][j - 1] + 1,
|
|
161
|
-
// 插入
|
|
162
|
-
matrix[i - 1][j] + 1
|
|
163
|
-
// 删除
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return matrix[b.length][a.length];
|
|
169
|
-
};
|
|
170
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
-
0 && (module.exports = {
|
|
172
|
-
amount,
|
|
173
|
-
generateAlphabetArray,
|
|
174
|
-
getChinese,
|
|
175
|
-
getChineseByStr,
|
|
176
|
-
getCookie,
|
|
177
|
-
getLength,
|
|
178
|
-
getProxyUrl,
|
|
179
|
-
getRandomColor,
|
|
180
|
-
getRandomString,
|
|
181
|
-
getSliceStr,
|
|
182
|
-
getStrLength,
|
|
183
|
-
getType,
|
|
184
|
-
isJson,
|
|
185
|
-
jsonParse,
|
|
186
|
-
levenshteinDistance,
|
|
187
|
-
replaceAll,
|
|
188
|
-
replaceByRules,
|
|
189
|
-
toString
|
|
190
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/node/file/index.ts
|
|
30
|
-
var file_exports = {};
|
|
31
|
-
__export(file_exports, {
|
|
32
|
-
replaceContentInFile: () => replaceContentInFile
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(file_exports);
|
|
35
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
36
|
-
var replaceContentInFile = async (filePath, targetContent, replacement) => {
|
|
37
|
-
try {
|
|
38
|
-
const data = await import_fs_extra.default.readFile(filePath, "utf8");
|
|
39
|
-
if (replacement && data.includes(replacement)) {
|
|
40
|
-
console.error(`已替换过:${filePath}`);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (!data.includes(targetContent)) {
|
|
44
|
-
console.error(`不包含目标内容:${targetContent}`);
|
|
45
|
-
throw new Error(`不包含目标内容:${targetContent}`);
|
|
46
|
-
}
|
|
47
|
-
const updatedData = data.replace(new RegExp(targetContent, "g"), replacement);
|
|
48
|
-
await import_fs_extra.default.writeFile(filePath, updatedData, "utf8");
|
|
49
|
-
console.log(`成功替换文件中的内容!`);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.error(`处理文件时发生错误:${err}`);
|
|
52
|
-
throw err;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
replaceContentInFile
|
|
58
|
-
});
|
package/dist/cjs/node/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/node/index.ts
|
|
31
|
-
var node_exports = {};
|
|
32
|
-
__export(node_exports, {
|
|
33
|
-
DataStore: () => import_nedb.default,
|
|
34
|
-
DataStoreOptions: () => import_nedb.DataStoreOptions
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(node_exports);
|
|
37
|
-
__reExport(node_exports, require("./jsonFile"), module.exports);
|
|
38
|
-
__reExport(node_exports, require("./mail"), module.exports);
|
|
39
|
-
__reExport(node_exports, require("./file"), module.exports);
|
|
40
|
-
var import_nedb = __toESM(require("nedb"));
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
DataStore,
|
|
44
|
-
DataStoreOptions,
|
|
45
|
-
...require("./jsonFile"),
|
|
46
|
-
...require("./mail"),
|
|
47
|
-
...require("./file")
|
|
48
|
-
});
|