light-h5-core-lib 2.8.0 → 2.8.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/LightCore.ts +49 -0
- package/common/base/BaseSingleton.ts +28 -0
- package/common/base/IClear.ts +5 -0
- package/common/base/IDestroy.ts +3 -0
- package/common/md5/{MD5.js → MD5.ts} +376 -346
- package/common/util/BeizerUtil.ts +87 -0
- package/common/util/{BitUtil.js → BitUtil.ts} +37 -43
- package/common/util/BooleanUtil.ts +15 -0
- package/common/util/Crc32Util.ts +30 -0
- package/common/util/DateUtil.ts +120 -0
- package/common/util/FloatDigitUtil.ts +55 -0
- package/common/util/NumberUtil.ts +15 -0
- package/common/util/PromiseUtil.ts +25 -0
- package/common/util/RandomNumUtil.ts +81 -0
- package/common/util/SelfDecrypt.ts +31 -0
- package/common/util/StringUtil.ts +83 -0
- package/common/util/UniqueIDUtil.ts +14 -0
- package/package.json +1 -1
- package/pool/PoolObj.ts +69 -0
- package/type/index.d.ts +81 -3
- package/LightCore.js +0 -44
- package/common/base/BaseSingleton.js +0 -23
- package/common/base/IClear.js +0 -2
- package/common/base/IDestroy.js +0 -2
- package/common/util/BeizerUtil.js +0 -83
- package/common/util/Crc32Util.js +0 -35
- package/common/util/CryptUtil.js +0 -43
- package/common/util/DateUtil.js +0 -89
- package/common/util/FloatDigitUtil.js +0 -22
- package/common/util/PromiseUtil.js +0 -74
- package/common/util/RandomNumUtil.js +0 -54
- package/common/util/StringUtil.js +0 -81
- package/common/util/UniqueIDUtil.js +0 -21
- package/pool/PoolObj.js +0 -79
package/pool/PoolObj.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { IClear } from "../common/base/IClear";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 对象池(泛型)
|
|
5
|
+
* @author Aonaufly
|
|
6
|
+
*/
|
|
7
|
+
export class PoolObj<T> implements IClear {
|
|
8
|
+
private _pool: T[];
|
|
9
|
+
private _cap: number;
|
|
10
|
+
/**
|
|
11
|
+
* @param cap 容量(容积)
|
|
12
|
+
*/
|
|
13
|
+
public constructor(cap: number = 5) {
|
|
14
|
+
this._cap = cap;
|
|
15
|
+
this._pool = [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public put(obj: T): boolean {
|
|
19
|
+
if (!obj || this._pool.length >= this._cap) return false;
|
|
20
|
+
this._pool.push(obj);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public one(): T {
|
|
25
|
+
if (this._pool.length == 0) return null;
|
|
26
|
+
return this._pool.shift();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 获取容量(容积)
|
|
31
|
+
*/
|
|
32
|
+
public get cap(): number {
|
|
33
|
+
return this._cap;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 获取当前数量(已经保存的元素个数)
|
|
38
|
+
*/
|
|
39
|
+
public get size(): number {
|
|
40
|
+
if (!this._pool) return 0;
|
|
41
|
+
return this._pool.length;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 清理对象池
|
|
46
|
+
*/
|
|
47
|
+
public clear(): void {
|
|
48
|
+
if (!this._pool) return;
|
|
49
|
+
if (this._pool.length == 0) return;
|
|
50
|
+
let obj: any;
|
|
51
|
+
for (let i: number = 0, j: number = this._pool.length; i < j; i++) {
|
|
52
|
+
obj = this._pool[i];
|
|
53
|
+
if (obj.destroy) {
|
|
54
|
+
obj.destroy();
|
|
55
|
+
} else if (obj.onDestroy) {
|
|
56
|
+
obj.onDestroy();
|
|
57
|
+
}
|
|
58
|
+
obj = null;
|
|
59
|
+
}
|
|
60
|
+
this._pool.length = 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public destroy(isCleared?: boolean): void {
|
|
64
|
+
if (!isCleared) {
|
|
65
|
+
this.clear();
|
|
66
|
+
}
|
|
67
|
+
this._pool && (this._pool = null);
|
|
68
|
+
}
|
|
69
|
+
}
|
package/type/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface IClear extends IDestroy {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* 对象池(泛型)
|
|
11
|
-
* @author
|
|
11
|
+
* @author Aonaufly
|
|
12
12
|
*/
|
|
13
13
|
export declare class PoolObj<T> implements IClear {
|
|
14
14
|
private _pool;
|
|
@@ -42,11 +42,15 @@ export declare abstract class BaseSingleton<T> implements IDestroy {
|
|
|
42
42
|
static getInstance<T>(c: {
|
|
43
43
|
new (): T;
|
|
44
44
|
}): T;
|
|
45
|
+
/**
|
|
46
|
+
* 相当于构造函数
|
|
47
|
+
*/
|
|
48
|
+
protected ctor(): void;
|
|
45
49
|
destroy(): void;
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* 位操作工具(从右向左←)
|
|
49
|
-
* @author
|
|
53
|
+
* @author Aonaufly
|
|
50
54
|
*/
|
|
51
55
|
export declare class BitUtil {
|
|
52
56
|
/**
|
|
@@ -106,6 +110,20 @@ export declare class DateUtil {
|
|
|
106
110
|
* @param millisecond 指定的毫秒数 0~999
|
|
107
111
|
*/
|
|
108
112
|
static getTodayAppointTimeStamp(nowSecond: number, hour: number, minute?: number, second?: number, millisecond?: number): number;
|
|
113
|
+
/**
|
|
114
|
+
* 获得剩余的过期时间秒(S)用于倒计时
|
|
115
|
+
* @param targetExpireSecond 过期的时间戳(s)
|
|
116
|
+
* @param curSecond 当前时间戳(s)
|
|
117
|
+
* @param offsetSecond 误差值(s) (targetExpireSecond + offsetSecond)用于延长/缩短一些过期时间
|
|
118
|
+
*/
|
|
119
|
+
static getRemainingSecond(targetExpireSecond: number, curSecond?: number, offsetSecond?: number): number;
|
|
120
|
+
/**
|
|
121
|
+
* 获得过期的时间戳(S)
|
|
122
|
+
* @param durationSecond 过期的时间倒计时(s)
|
|
123
|
+
* @param curSecond 当前的时间(s)
|
|
124
|
+
* @return 过期的时间戳(s)
|
|
125
|
+
*/
|
|
126
|
+
static getExpireSecond(durationSecond: number, curSecond?: number): number;
|
|
109
127
|
}
|
|
110
128
|
/**
|
|
111
129
|
* Float精度
|
|
@@ -118,6 +136,14 @@ export declare class FloatDigitUtil {
|
|
|
118
136
|
* @param digit 精度
|
|
119
137
|
*/
|
|
120
138
|
static formatFloat(fNum: number, digit: number): number;
|
|
139
|
+
/**
|
|
140
|
+
* 小数的格式化
|
|
141
|
+
*/
|
|
142
|
+
static formatDecimalNumber(num: number, factor: number, isRound?: boolean): number;
|
|
143
|
+
/**
|
|
144
|
+
* 小数的格式化
|
|
145
|
+
*/
|
|
146
|
+
static formatDecimalString(num: number, factor: number, isRound?: boolean, isSupplementZero?: boolean): string;
|
|
121
147
|
}
|
|
122
148
|
/**
|
|
123
149
|
* 随机数生成工具
|
|
@@ -138,6 +164,21 @@ export declare class RandomNumUtil {
|
|
|
138
164
|
* 打乱数组
|
|
139
165
|
*/
|
|
140
166
|
static shuffleSort<T>(arr: T[]): void;
|
|
167
|
+
/**
|
|
168
|
+
* 获得偏振系数
|
|
169
|
+
* @param factor 偏振因子(>0)
|
|
170
|
+
* @param negativeIntRadio 负数的比率(> 0的整数)
|
|
171
|
+
* @param positiveIntRadio 正数的比率 (>0的整数)
|
|
172
|
+
* @return -factor 或者factor
|
|
173
|
+
*/
|
|
174
|
+
static getPolarizationFactor(factor?: number, negativeIntRadio?: number, positiveIntRadio?: number): number;
|
|
175
|
+
/**
|
|
176
|
+
* 按照比率获得随机数(对于整数)
|
|
177
|
+
* @param min 最小数
|
|
178
|
+
* @param max 最大数
|
|
179
|
+
* @param radioArr 比率
|
|
180
|
+
*/
|
|
181
|
+
static randomNumWithRadio(min: number, max: number, radioArr: number[]): number;
|
|
141
182
|
}
|
|
142
183
|
/**
|
|
143
184
|
* 字符串工具
|
|
@@ -149,7 +190,11 @@ export declare class StringUtil {
|
|
|
149
190
|
* @param str 源字符串
|
|
150
191
|
* @param args 填充参数
|
|
151
192
|
*/
|
|
152
|
-
static format(str: string, ...args:
|
|
193
|
+
static format(str: string, ...args: any): string;
|
|
194
|
+
/**
|
|
195
|
+
* 将字符串中所有的\/替换成/
|
|
196
|
+
*/
|
|
197
|
+
static replaceBackslash(input: string): string;
|
|
153
198
|
private static code2utf8;
|
|
154
199
|
/**
|
|
155
200
|
* 将字符串转化成UTF8的Buffer
|
|
@@ -253,5 +298,38 @@ export declare class Crc32Util {
|
|
|
253
298
|
*/
|
|
254
299
|
static getCrc32String(str: string, crc?: number): string;
|
|
255
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Bool类型处理
|
|
303
|
+
* @author Aonaufly
|
|
304
|
+
*/
|
|
305
|
+
export declare class BooleanUtil {
|
|
306
|
+
/**
|
|
307
|
+
* 获得Proto中的Bool值
|
|
308
|
+
*/
|
|
309
|
+
static getProtoBool(data: any, key: string, defaultValue?: boolean): boolean;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* 数值类型处理
|
|
313
|
+
* @author Aonaufly
|
|
314
|
+
*/
|
|
315
|
+
export declare class NumberUtil {
|
|
316
|
+
/**
|
|
317
|
+
* 获得Proto中的数字
|
|
318
|
+
*/
|
|
319
|
+
static getProtoNum(data: any, key: string, defaultValue?: number): number;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* 解码
|
|
323
|
+
* @author Aonaufly
|
|
324
|
+
*/
|
|
325
|
+
export declare class SelfDecrypt {
|
|
326
|
+
private static b64Decode;
|
|
327
|
+
private static b64Encode;
|
|
328
|
+
private static xorBytes;
|
|
329
|
+
/**
|
|
330
|
+
* 解码
|
|
331
|
+
*/
|
|
332
|
+
static decryptBase64(b64: string, key: string): string;
|
|
333
|
+
}
|
|
256
334
|
|
|
257
335
|
export {};
|
package/LightCore.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Crc32Util = exports.PromiseUtil = exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.MD5 = exports.BaseSingleton = exports.PoolObj = void 0;
|
|
7
|
-
var PoolObj_1 = require("./pool/PoolObj");
|
|
8
|
-
Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
|
|
9
|
-
var BaseSingleton_1 = require("./common/base/BaseSingleton");
|
|
10
|
-
Object.defineProperty(exports, "BaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
|
|
11
|
-
var BitUtil_1 = require("./common/util/BitUtil");
|
|
12
|
-
Object.defineProperty(exports, "BitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
|
|
13
|
-
var DateUtil_1 = require("./common/util/DateUtil");
|
|
14
|
-
Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
|
|
15
|
-
var FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
|
|
16
|
-
Object.defineProperty(exports, "FloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
|
|
17
|
-
var RandomNumUtil_1 = require("./common/util/RandomNumUtil");
|
|
18
|
-
Object.defineProperty(exports, "RandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
|
|
19
|
-
var StringUtil_1 = require("./common/util/StringUtil");
|
|
20
|
-
Object.defineProperty(exports, "StringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
|
|
21
|
-
var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
|
|
22
|
-
Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
|
|
23
|
-
var BeizerUtil_1 = require("./common/util/BeizerUtil");
|
|
24
|
-
Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
|
|
25
|
-
var MD5_1 = require("./common/md5/MD5");
|
|
26
|
-
Object.defineProperty(exports, "MD5", { enumerable: true, get: function () { return MD5_1.MD5; } });
|
|
27
|
-
var PromiseUtil_1 = __importDefault(require("./common/util/PromiseUtil"));
|
|
28
|
-
exports.PromiseUtil = PromiseUtil_1.default;
|
|
29
|
-
var Crc32Util_1 = __importDefault(require("./common/util/Crc32Util"));
|
|
30
|
-
exports.Crc32Util = Crc32Util_1.default;
|
|
31
|
-
module.exports = {
|
|
32
|
-
PoolObj: PoolObj_1.PoolObj,
|
|
33
|
-
BaseSingleton: BaseSingleton_1.BaseSingleton,
|
|
34
|
-
MD5: MD5_1.MD5,
|
|
35
|
-
BitUtil: BitUtil_1.BitUtil,
|
|
36
|
-
DateUtil: DateUtil_1.DateUtil,
|
|
37
|
-
FloatDigitUtil: FloatDigitUtil_1.FloatDigitUtil,
|
|
38
|
-
RandomNumUtil: RandomNumUtil_1.RandomNumUtil,
|
|
39
|
-
StringUtil: StringUtil_1.StringUtil,
|
|
40
|
-
UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
|
|
41
|
-
BeizerUtil: BeizerUtil_1.BeizerUtil,
|
|
42
|
-
PromiseUtil: PromiseUtil_1.default,
|
|
43
|
-
Crc32Util: Crc32Util_1.default
|
|
44
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseSingleton = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 泛型单例基类
|
|
6
|
-
* @author Aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var BaseSingleton = /** @class */ (function () {
|
|
9
|
-
function BaseSingleton() {
|
|
10
|
-
}
|
|
11
|
-
BaseSingleton.getInstance = function (c) {
|
|
12
|
-
if (this._instance == null) {
|
|
13
|
-
this._instance = new c();
|
|
14
|
-
}
|
|
15
|
-
return this._instance;
|
|
16
|
-
};
|
|
17
|
-
BaseSingleton.prototype.destroy = function () {
|
|
18
|
-
BaseSingleton._instance = null;
|
|
19
|
-
};
|
|
20
|
-
BaseSingleton._instance = null;
|
|
21
|
-
return BaseSingleton;
|
|
22
|
-
}());
|
|
23
|
-
exports.BaseSingleton = BaseSingleton;
|
package/common/base/IClear.js
DELETED
package/common/base/IDestroy.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BeizerUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 贝塞尔曲线运动
|
|
6
|
-
* @author Aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var BeizerUtil = /** @class */ (function () {
|
|
9
|
-
function BeizerUtil() {
|
|
10
|
-
}
|
|
11
|
-
//#region 获得当前坐标
|
|
12
|
-
/**
|
|
13
|
-
* 获得当前坐标
|
|
14
|
-
* @param timer 时间[0,1]
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
BeizerUtil.getPosition = function (points, timer) {
|
|
18
|
-
var x = 0, y = 0;
|
|
19
|
-
var bezier;
|
|
20
|
-
for (var i = 0, n = points.length; i < n; i++) {
|
|
21
|
-
bezier =
|
|
22
|
-
Math.min(Math.pow(1 - timer, n - i - 1) * Math.pow(timer, i)) *
|
|
23
|
-
BeizerUtil.calculationC(i, n);
|
|
24
|
-
x += points[i].x * bezier;
|
|
25
|
-
y += points[i].y * bezier;
|
|
26
|
-
}
|
|
27
|
-
return { x: x, y: y };
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
//region 获得路线的长度
|
|
31
|
-
BeizerUtil.distance = function (p1, p2) {
|
|
32
|
-
var dx = p2.x - p1.x;
|
|
33
|
-
var dy = p2.y - p1.y;
|
|
34
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* 获得整个路线的长度
|
|
38
|
-
* @param precision 精确度(微积分方案)
|
|
39
|
-
*/
|
|
40
|
-
BeizerUtil.getLength = function (points, precision) {
|
|
41
|
-
if (precision === void 0) { precision = 100; }
|
|
42
|
-
var length = 0;
|
|
43
|
-
var point1;
|
|
44
|
-
var point2;
|
|
45
|
-
for (var t = 0; t < 1; t += 1 / precision) {
|
|
46
|
-
point1 = BeizerUtil.getBezierPoint(points, t);
|
|
47
|
-
point2 = BeizerUtil.getBezierPoint(points, t + 1 / precision);
|
|
48
|
-
length += BeizerUtil.distance(point1, point2);
|
|
49
|
-
}
|
|
50
|
-
return length;
|
|
51
|
-
};
|
|
52
|
-
BeizerUtil.calculationC = function (i, n) {
|
|
53
|
-
return (BeizerUtil.factorial(n - 1) /
|
|
54
|
-
(BeizerUtil.factorial(i) * BeizerUtil.factorial(n - 1 - i)));
|
|
55
|
-
};
|
|
56
|
-
BeizerUtil.factorial = function (num) {
|
|
57
|
-
if (num < 0) {
|
|
58
|
-
return 1;
|
|
59
|
-
}
|
|
60
|
-
else if (num === 0 || num === 1) {
|
|
61
|
-
return 1;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return num * BeizerUtil.factorial(num - 1);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
BeizerUtil.getBezierPoint = function (points, t) {
|
|
68
|
-
if (points.length === 1) {
|
|
69
|
-
return points[0];
|
|
70
|
-
}
|
|
71
|
-
var nextPoints = [];
|
|
72
|
-
var x;
|
|
73
|
-
var y;
|
|
74
|
-
for (var i = 0; i < points.length - 1; i++) {
|
|
75
|
-
x = (1 - t) * points[i].x + t * points[i + 1].x;
|
|
76
|
-
y = (1 - t) * points[i].y + t * points[i + 1].y;
|
|
77
|
-
nextPoints.push({ x: x, y: y });
|
|
78
|
-
}
|
|
79
|
-
return BeizerUtil.getBezierPoint(nextPoints, t);
|
|
80
|
-
};
|
|
81
|
-
return BeizerUtil;
|
|
82
|
-
}());
|
|
83
|
-
exports.BeizerUtil = BeizerUtil;
|
package/common/util/Crc32Util.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Crc32验证工具
|
|
5
|
-
* @author Aonaufly
|
|
6
|
-
*/
|
|
7
|
-
var Crc32Util = /** @class */ (function () {
|
|
8
|
-
function Crc32Util() {
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Crc32 number
|
|
12
|
-
*/
|
|
13
|
-
Crc32Util.getCrc32Number = function (str, crc) {
|
|
14
|
-
if (crc === void 0) { crc = 0; }
|
|
15
|
-
var n = 0;
|
|
16
|
-
var x;
|
|
17
|
-
crc = crc ^ (-1);
|
|
18
|
-
for (var i = 0, iTop = str.length; i < iTop; i++) {
|
|
19
|
-
n = (crc ^ str.charCodeAt(i)) & 0xFF;
|
|
20
|
-
x = "0x" + Crc32Util.table.substr(n * 9, 8);
|
|
21
|
-
crc = (crc >>> 8) ^ x;
|
|
22
|
-
}
|
|
23
|
-
return crc ^ (-1);
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Crc32 string
|
|
27
|
-
*/
|
|
28
|
-
Crc32Util.getCrc32String = function (str, crc) {
|
|
29
|
-
if (crc === void 0) { crc = 0; }
|
|
30
|
-
return Crc32Util.getCrc32Number(str, crc).toString(16);
|
|
31
|
-
};
|
|
32
|
-
Crc32Util.table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";
|
|
33
|
-
return Crc32Util;
|
|
34
|
-
}());
|
|
35
|
-
exports.default = Crc32Util;
|
package/common/util/CryptUtil.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CryptUtil = void 0;
|
|
7
|
-
var crypto_es_1 = __importDefault(require("crypto-es"));
|
|
8
|
-
/**
|
|
9
|
-
* 加解密工具
|
|
10
|
-
* @author Aonaufly
|
|
11
|
-
*/
|
|
12
|
-
var CryptUtil = /** @class */ (function () {
|
|
13
|
-
function CryptUtil() {
|
|
14
|
-
}
|
|
15
|
-
//#region AES-256 ECB
|
|
16
|
-
/** 加密函数AES-256 ECB */
|
|
17
|
-
CryptUtil.encryptAes = function (plainText, key) {
|
|
18
|
-
var keyBytes = crypto_es_1.default.enc.Utf8.parse(key);
|
|
19
|
-
var encrypted = crypto_es_1.default.AES.encrypt(crypto_es_1.default.enc.Utf8.parse(plainText), keyBytes, {
|
|
20
|
-
mode: crypto_es_1.default.mode.ECB,
|
|
21
|
-
padding: crypto_es_1.default.pad.Pkcs7,
|
|
22
|
-
});
|
|
23
|
-
return encrypted.toString();
|
|
24
|
-
};
|
|
25
|
-
/**解密函数AES-256 ECB*/
|
|
26
|
-
CryptUtil.decryptAes = function (cipherText, key) {
|
|
27
|
-
var keyBytes = crypto_es_1.default.enc.Utf8.parse(key);
|
|
28
|
-
var decrypted = crypto_es_1.default.AES.decrypt(cipherText, keyBytes, {
|
|
29
|
-
mode: crypto_es_1.default.mode.ECB,
|
|
30
|
-
padding: crypto_es_1.default.pad.Pkcs7,
|
|
31
|
-
});
|
|
32
|
-
return crypto_es_1.default.enc.Utf8.stringify(decrypted);
|
|
33
|
-
};
|
|
34
|
-
//#endregion
|
|
35
|
-
/**
|
|
36
|
-
* MD5
|
|
37
|
-
*/
|
|
38
|
-
CryptUtil.md5 = function (text) {
|
|
39
|
-
return crypto_es_1.default.MD5(text).toString();
|
|
40
|
-
};
|
|
41
|
-
return CryptUtil;
|
|
42
|
-
}());
|
|
43
|
-
exports.CryptUtil = CryptUtil;
|
package/common/util/DateUtil.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 日期(时间)工具
|
|
6
|
-
* @author aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var DateUtil = /** @class */ (function () {
|
|
9
|
-
function DateUtil() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 获取指定时间的时间戳 (单位:ms)
|
|
13
|
-
* @param date 如: "2020-3-14 11:30:30"
|
|
14
|
-
*/
|
|
15
|
-
DateUtil.getTargetTimeStamp = function (date) {
|
|
16
|
-
return new Date(date).getTime();
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* 获取指定时间的时间秒 (单位:s)
|
|
20
|
-
* @param date 如: "2020-3-14 11:30:30"
|
|
21
|
-
*/
|
|
22
|
-
DateUtil.getTargetSeconds = function (date) {
|
|
23
|
-
return Math.floor(DateUtil.getTargetTimeStamp(date) / 1000);
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* 格式化时间(时,分,秒)
|
|
27
|
-
* @param s 秒
|
|
28
|
-
* @param separator 分隔符(default: ":")
|
|
29
|
-
* @param isSingle0 是否补0(default:true)
|
|
30
|
-
* @param isDiscardH 小时数为0时,是否舍弃显示变成分,秒(default:false)
|
|
31
|
-
*/
|
|
32
|
-
DateUtil.format_HMS = function (s, separator, isSingle0, isDiscardH) {
|
|
33
|
-
if (separator === void 0) { separator = ":"; }
|
|
34
|
-
if (isSingle0 === void 0) { isSingle0 = true; }
|
|
35
|
-
if (isDiscardH === void 0) { isDiscardH = false; }
|
|
36
|
-
var h = Math.floor(s / 3600);
|
|
37
|
-
if (isDiscardH && h == 0) {
|
|
38
|
-
return DateUtil.format_MS(s, separator, isSingle0);
|
|
39
|
-
}
|
|
40
|
-
var m = Math.floor((s - h * 3600) / 60);
|
|
41
|
-
s = s - h * 3600 - m * 60;
|
|
42
|
-
var result = isSingle0 ? (h < 10 ? "0".concat(h) : h.toString()) : h.toString();
|
|
43
|
-
result += separator;
|
|
44
|
-
result = result + (isSingle0 ? (m < 10 ? "0".concat(m) : m.toString()) : m.toString());
|
|
45
|
-
result += separator;
|
|
46
|
-
result = result + (isSingle0 ? (s < 10 ? "0".concat(s) : s.toString()) : s.toString());
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* 格式化时间(分,秒)
|
|
51
|
-
* @param s 秒
|
|
52
|
-
* @param separator 分隔符(default: ":")
|
|
53
|
-
* @param isSingle0 是否补0(default:true)
|
|
54
|
-
*/
|
|
55
|
-
DateUtil.format_MS = function (s, separator, isSingle0) {
|
|
56
|
-
if (separator === void 0) { separator = ":"; }
|
|
57
|
-
if (isSingle0 === void 0) { isSingle0 = true; }
|
|
58
|
-
var m = Math.floor(s / 60);
|
|
59
|
-
s = s - m * 60;
|
|
60
|
-
var result = isSingle0 ? (m < 10 ? "0".concat(m) : m.toString()) : m.toString();
|
|
61
|
-
result += separator;
|
|
62
|
-
result = result + (isSingle0 ? (s < 10 ? "0".concat(s) : s.toString()) : s.toString());
|
|
63
|
-
return result;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* 获取下一天的时间(凌晨)秒 存在1ms误差可以忽略不计
|
|
67
|
-
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
68
|
-
* @return 下一天的时间Second
|
|
69
|
-
* */
|
|
70
|
-
DateUtil.getNextDayTimeStamp = function (nowSecond) {
|
|
71
|
-
return DateUtil.getTodayAppointTimeStamp(nowSecond, 23, 59, 59, 999);
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* 获取今日指定的时间秒, 例如今日20:00
|
|
75
|
-
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
76
|
-
* @param hour 指定的小时数 0~23
|
|
77
|
-
* @param minute 指定的分钟数 0~59
|
|
78
|
-
* @param second 指定的秒数 0~59
|
|
79
|
-
* @param millisecond 指定的毫秒数 0~999
|
|
80
|
-
*/
|
|
81
|
-
DateUtil.getTodayAppointTimeStamp = function (nowSecond, hour, minute, second, millisecond) {
|
|
82
|
-
if (minute === void 0) { minute = 0; }
|
|
83
|
-
if (second === void 0) { second = 0; }
|
|
84
|
-
if (millisecond === void 0) { millisecond = 0; }
|
|
85
|
-
return Math.ceil(new Date(new Date(nowSecond * 1000).setHours(hour, minute, second, millisecond)).getTime() / 1000);
|
|
86
|
-
};
|
|
87
|
-
return DateUtil;
|
|
88
|
-
}());
|
|
89
|
-
exports.DateUtil = DateUtil;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FloatDigitUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Float精度
|
|
6
|
-
* @author aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var FloatDigitUtil = /** @class */ (function () {
|
|
9
|
-
function FloatDigitUtil() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 确定小数的精度<b style="color:red">2个小数相加会有精度错误</b>
|
|
13
|
-
* @param fNum 小数
|
|
14
|
-
* @param digit 精度
|
|
15
|
-
*/
|
|
16
|
-
FloatDigitUtil.formatFloat = function (fNum, digit) {
|
|
17
|
-
var m = Math.pow(10, digit);
|
|
18
|
-
return parseInt((fNum * m).toString(), 10) / m;
|
|
19
|
-
};
|
|
20
|
-
return FloatDigitUtil;
|
|
21
|
-
}());
|
|
22
|
-
exports.FloatDigitUtil = FloatDigitUtil;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
/**
|
|
40
|
-
* 异步处理工具
|
|
41
|
-
* @author Aonaufly
|
|
42
|
-
*/
|
|
43
|
-
var PromiseUtil = /** @class */ (function () {
|
|
44
|
-
function PromiseUtil() {
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* 执行所有异步并返回数据
|
|
48
|
-
*/
|
|
49
|
-
PromiseUtil.all = function (promiseArr) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
53
|
-
var promises = Array.from(promiseArr);
|
|
54
|
-
var r = [];
|
|
55
|
-
var len = promises.length;
|
|
56
|
-
var count = 0;
|
|
57
|
-
var _loop_1 = function (i) {
|
|
58
|
-
Promise.resolve(promises[i]).then(function (o) {
|
|
59
|
-
r[i] = o;
|
|
60
|
-
if (++count === len) {
|
|
61
|
-
resolve(r);
|
|
62
|
-
}
|
|
63
|
-
}).catch(function (e) { return reject(e); });
|
|
64
|
-
};
|
|
65
|
-
for (var i = 0; i < len; i++) {
|
|
66
|
-
_loop_1(i);
|
|
67
|
-
}
|
|
68
|
-
})];
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
return PromiseUtil;
|
|
73
|
-
}());
|
|
74
|
-
exports.default = PromiseUtil;
|