ztxkutils 2.2.8 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crypto-c481f616.js +6796 -0
- package/dist/crypto.d.ts +44 -0
- package/dist/crypto.js +2 -0
- package/dist/hooks.js +1 -1
- package/dist/index.js +7 -5
- package/dist/{reqUrl-cf7d6223.js → reqUrl-c74197bf.js} +6 -3
- package/dist/{reqUrl-68c864fb.js → reqUrl-eba8e6f5.js} +9 -3
- package/dist/reqUrl.js +1 -1
- package/dist/request-56290d29.js +2684 -0
- package/dist/request.d.ts +2 -1
- package/dist/request.js +4 -2
- package/dist/{tools-e7505c92.js → tools-8f036dd3.js} +3 -1
- package/dist/tools.js +2 -2
- package/dist/tslib.es6-f9459658.js +83 -0
- package/dist/{validate-01242f5f.js → validate-ebe369e9.js} +5 -0
- package/dist/validate.d.ts +5 -0
- package/dist/validate.js +1 -1
- package/package.json +2 -1
- package/dist/tools-48c24adb.js +0 -200
- package/dist/tools-49b33116.js +0 -195
- package/dist/tools-8207f0a0.js +0 -197
- package/dist/tools-e1b35b23.js +0 -209
- package/dist/tools-e7de0bcc.js +0 -205
- package/dist/tools-e94e4c20.js +0 -209
- package/dist/validate-56d8f230.js +0 -61
- package/dist/validate-743d8f98.js +0 -60
- package/dist/validate-7f5dd1b3.js +0 -60
- package/dist/validate-8cbc61e4.js +0 -60
- package/dist/validate-bf84ec9c.js +0 -60
- package/dist/validate-cc61f65f.js +0 -60
- package/dist/validate-e4351b64.js +0 -60
package/dist/request.d.ts
CHANGED
@@ -4,5 +4,6 @@
|
|
4
4
|
import { AxiosRequestConfig } from 'axios';
|
5
5
|
export interface IOptions extends AxiosRequestConfig {
|
6
6
|
isFormData?: boolean;
|
7
|
+
encryptionType?: 'aes' | 'des' | boolean;
|
7
8
|
}
|
8
|
-
export default function request(
|
9
|
+
export default function request(myOptions: IOptions): import("axios").AxiosPromise<any>;
|
package/dist/request.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
import './tslib.es6-
|
1
|
+
import './tslib.es6-f9459658.js';
|
2
2
|
import 'axios';
|
3
3
|
import 'ztxkui';
|
4
|
-
export { a as default } from './request-
|
4
|
+
export { a as default } from './request-56290d29.js';
|
5
5
|
import './authority-17b7fde2.js';
|
6
|
+
import './crypto-c481f616.js';
|
7
|
+
import 'crypto';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as __assign, a as __spreadArray } from './tslib.es6-
|
1
|
+
import { _ as __assign, a as __spreadArray } from './tslib.es6-f9459658.js';
|
2
2
|
import dayjs from 'dayjs';
|
3
3
|
import { divide as divide$1, round, plus, minus, times } from 'number-precision';
|
4
4
|
|
@@ -14,6 +14,8 @@ function timeTransfrom(timeParams) {
|
|
14
14
|
var toKeyItem = toKey[i];
|
15
15
|
var formatItem = Array.isArray(format)
|
16
16
|
? format[i]
|
17
|
+
? format[i]
|
18
|
+
: 'YYYY-MM-DD'
|
17
19
|
: format
|
18
20
|
? format
|
19
21
|
: 'YYYY-MM-DD';
|
package/dist/tools.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import './tslib.es6-
|
1
|
+
import './tslib.es6-f9459658.js';
|
2
2
|
import 'dayjs';
|
3
3
|
export { minus, plus, times } from 'number-precision';
|
4
|
-
export { c as clearAssignStr, d as divide, e as exactRound, i as isEqualByKey, l as loadFileRename, a as timeTransfrom, b as toThousand, f as transformFileSize } from './tools-
|
4
|
+
export { c as clearAssignStr, d as divide, e as exactRound, i as isEqualByKey, l as loadFileRename, a as timeTransfrom, b as toThousand, f as transformFileSize } from './tools-8f036dd3.js';
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/*! *****************************************************************************
|
2
|
+
Copyright (c) Microsoft Corporation.
|
3
|
+
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
5
|
+
purpose with or without fee is hereby granted.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
***************************************************************************** */
|
15
|
+
|
16
|
+
var __assign = function() {
|
17
|
+
__assign = Object.assign || function __assign(t) {
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
19
|
+
s = arguments[i];
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
21
|
+
}
|
22
|
+
return t;
|
23
|
+
};
|
24
|
+
return __assign.apply(this, arguments);
|
25
|
+
};
|
26
|
+
|
27
|
+
function __rest(s, e) {
|
28
|
+
var t = {};
|
29
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
30
|
+
t[p] = s[p];
|
31
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
32
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
33
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
34
|
+
t[p[i]] = s[p[i]];
|
35
|
+
}
|
36
|
+
return t;
|
37
|
+
}
|
38
|
+
|
39
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
40
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
41
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
42
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
43
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
44
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
45
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
46
|
+
});
|
47
|
+
}
|
48
|
+
|
49
|
+
function __generator(thisArg, body) {
|
50
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
51
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
52
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
53
|
+
function step(op) {
|
54
|
+
if (f) throw new TypeError("Generator is already executing.");
|
55
|
+
while (_) try {
|
56
|
+
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;
|
57
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
58
|
+
switch (op[0]) {
|
59
|
+
case 0: case 1: t = op; break;
|
60
|
+
case 4: _.label++; return { value: op[1], done: false };
|
61
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
62
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
63
|
+
default:
|
64
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
65
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
66
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
67
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
68
|
+
if (t[2]) _.ops.pop();
|
69
|
+
_.trys.pop(); continue;
|
70
|
+
}
|
71
|
+
op = body.call(thisArg, _);
|
72
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
73
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
function __spreadArray(to, from) {
|
78
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
79
|
+
to[j] = from[i];
|
80
|
+
return to;
|
81
|
+
}
|
82
|
+
|
83
|
+
export { __assign as _, __spreadArray as a, __rest as b, __awaiter as c, __generator as d };
|
@@ -32,6 +32,10 @@ var validate = {
|
|
32
32
|
* @description 密码验证
|
33
33
|
*/
|
34
34
|
passwordValidate: /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$)^.{8,16}$/,
|
35
|
+
/**
|
36
|
+
* @description 空格验证
|
37
|
+
*/
|
38
|
+
spaceValidate: /^[^\s]*$/g,
|
35
39
|
};
|
36
40
|
var commonMessage = {
|
37
41
|
smallLenMessage: function (type) {
|
@@ -50,6 +54,7 @@ var commonMessage = {
|
|
50
54
|
idCardMessage: '请输入正确的身份证',
|
51
55
|
emailMessage: '请输入正确的邮箱',
|
52
56
|
passwordMessage: '密码由8-16位的字母+数字,字母+特殊字符,数字+特殊字符组成',
|
57
|
+
spaceMessage: '请勿输入空格',
|
53
58
|
};
|
54
59
|
|
55
60
|
var validate$1 = /*#__PURE__*/Object.freeze({
|
package/dist/validate.d.ts
CHANGED
@@ -31,6 +31,10 @@ declare const validate: {
|
|
31
31
|
* @description 密码验证
|
32
32
|
*/
|
33
33
|
passwordValidate: RegExp;
|
34
|
+
/**
|
35
|
+
* @description 空格验证
|
36
|
+
*/
|
37
|
+
spaceValidate: RegExp;
|
34
38
|
};
|
35
39
|
declare const commonMessage: {
|
36
40
|
smallLenMessage(type?: string): string;
|
@@ -40,5 +44,6 @@ declare const commonMessage: {
|
|
40
44
|
idCardMessage: string;
|
41
45
|
emailMessage: string;
|
42
46
|
passwordMessage: string;
|
47
|
+
spaceMessage: string;
|
43
48
|
};
|
44
49
|
export { validate, commonMessage };
|
package/dist/validate.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { c as commonMessage, a as validate } from './validate-
|
1
|
+
export { c as commonMessage, a as validate } from './validate-ebe369e9.js';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ztxkutils",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.3.1",
|
4
4
|
"description": "",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/index.js",
|
@@ -44,6 +44,7 @@
|
|
44
44
|
"ztxkui": "^0.4.1"
|
45
45
|
},
|
46
46
|
"dependencies": {
|
47
|
+
"crypto-js": "^4.1.1",
|
47
48
|
"js-base64": "^3.6.0",
|
48
49
|
"screenfull": "^5.1.0",
|
49
50
|
"sockjs-client": "^1.5.1",
|
package/dist/tools-48c24adb.js
DELETED
@@ -1,200 +0,0 @@
|
|
1
|
-
import { _ as __assign, a as __spreadArray } from './tslib.es6-b9033aad.js';
|
2
|
-
import dayjs from 'dayjs';
|
3
|
-
import { divide as divide$1, round, plus, minus, times } from 'number-precision';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* @description 时间格式转换
|
7
|
-
*/
|
8
|
-
function timeTransfrom(timeParams) {
|
9
|
-
var _a, _b, _c, _d, _e;
|
10
|
-
var params = timeParams.params, fromKey = timeParams.fromKey, toKey = timeParams.toKey, _f = timeParams.type, type = _f === void 0 ? 'string' : _f;
|
11
|
-
var copyParams = __assign({}, params);
|
12
|
-
for (var i = 0; i < fromKey.length; i++) {
|
13
|
-
var fromKeyItem = fromKey[i];
|
14
|
-
var toKeyItem = toKey[i];
|
15
|
-
// 从一个键转换成两个键
|
16
|
-
if (typeof fromKeyItem === 'string' && typeof toKeyItem === 'object') {
|
17
|
-
if (type === 'string' && copyParams[fromKeyItem]) {
|
18
|
-
var _g = copyParams[fromKeyItem], startMoment = _g[0], endMoment = _g[1];
|
19
|
-
var start = void 0, end = void 0;
|
20
|
-
if (dayjs.isDayjs(startMoment)) {
|
21
|
-
start = startMoment.format('YYYY-MM-DD');
|
22
|
-
}
|
23
|
-
if (dayjs.isDayjs(endMoment)) {
|
24
|
-
end = endMoment.format('YYYY-MM-DD');
|
25
|
-
}
|
26
|
-
delete copyParams[fromKeyItem];
|
27
|
-
copyParams = __assign(__assign({}, copyParams), (_a = {}, _a[toKeyItem[0]] = start, _a[toKeyItem[1]] = end, _a));
|
28
|
-
}
|
29
|
-
else {
|
30
|
-
copyParams = __assign(__assign({}, copyParams), (_b = {}, _b[toKeyItem[0]] = undefined, _b[toKeyItem[1]] = undefined, _b));
|
31
|
-
}
|
32
|
-
}
|
33
|
-
// 从一个键转换成一个键
|
34
|
-
if (typeof fromKeyItem === 'string' && typeof toKeyItem === 'string') {
|
35
|
-
if (type === 'string') {
|
36
|
-
var _dayjsObj = copyParams[fromKeyItem];
|
37
|
-
var start = void 0;
|
38
|
-
if (dayjs.isDayjs(_dayjsObj)) {
|
39
|
-
start = _dayjsObj.format('YYYY-MM-DD');
|
40
|
-
}
|
41
|
-
delete copyParams[fromKeyItem];
|
42
|
-
copyParams = __assign(__assign({}, copyParams), (_c = {}, _c[toKeyItem] = start, _c));
|
43
|
-
}
|
44
|
-
if (type === 'object') {
|
45
|
-
var start = copyParams[fromKeyItem]
|
46
|
-
? dayjs(copyParams[fromKeyItem])
|
47
|
-
: undefined;
|
48
|
-
delete copyParams[fromKeyItem];
|
49
|
-
copyParams = __assign(__assign({}, copyParams), (_d = {}, _d[toKeyItem] = start, _d));
|
50
|
-
}
|
51
|
-
}
|
52
|
-
// 从两个键转换成一个键
|
53
|
-
if (typeof fromKeyItem === 'object' && typeof toKeyItem === 'string') {
|
54
|
-
if (type === 'object') {
|
55
|
-
var startMoment = fromKeyItem[0], endMoment = fromKeyItem[1];
|
56
|
-
var intime = copyParams[toKeyItem] || [null, null];
|
57
|
-
if (copyParams[startMoment]) {
|
58
|
-
intime[0] = dayjs(copyParams[startMoment]);
|
59
|
-
delete copyParams[startMoment];
|
60
|
-
}
|
61
|
-
if (copyParams[endMoment]) {
|
62
|
-
intime[1] = dayjs(copyParams[endMoment]);
|
63
|
-
delete copyParams[endMoment];
|
64
|
-
}
|
65
|
-
if (intime[0] == null || intime[1] == null) {
|
66
|
-
intime = null;
|
67
|
-
}
|
68
|
-
copyParams = __assign(__assign({}, copyParams), (_e = {}, _e[toKeyItem] = intime, _e));
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
return copyParams;
|
73
|
-
}
|
74
|
-
function divide(num1, num2) {
|
75
|
-
var others = [];
|
76
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
77
|
-
others[_i - 2] = arguments[_i];
|
78
|
-
}
|
79
|
-
try {
|
80
|
-
return divide$1.apply(void 0, __spreadArray([num1, num2], others));
|
81
|
-
}
|
82
|
-
catch (err) {
|
83
|
-
console.log(err);
|
84
|
-
return 0;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
/**
|
88
|
-
* @description 精确四舍五入后保留几位小数
|
89
|
-
*/
|
90
|
-
function exactRound(num, ratio) {
|
91
|
-
var typeNum = typeof num;
|
92
|
-
if (typeNum !== 'number' && typeNum !== 'string') {
|
93
|
-
return num;
|
94
|
-
}
|
95
|
-
try {
|
96
|
-
return round(num, ratio).toFixed(ratio);
|
97
|
-
}
|
98
|
-
catch (err) {
|
99
|
-
console.error(err);
|
100
|
-
return num;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
/**
|
104
|
-
* @description 添加千分符符号
|
105
|
-
*/
|
106
|
-
function toThousand(num) {
|
107
|
-
var typeNum = typeof num;
|
108
|
-
if (typeNum !== 'number' && typeNum !== 'string') {
|
109
|
-
return num;
|
110
|
-
}
|
111
|
-
var str = (num + '').replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,');
|
112
|
-
return str;
|
113
|
-
}
|
114
|
-
/**
|
115
|
-
* @description 去除指定字符串
|
116
|
-
*/
|
117
|
-
function clearAssignStr(str, originalStr) {
|
118
|
-
if (!originalStr) {
|
119
|
-
return originalStr;
|
120
|
-
}
|
121
|
-
if (originalStr.startsWith(str)) {
|
122
|
-
return originalStr.replace(str, '');
|
123
|
-
}
|
124
|
-
return originalStr;
|
125
|
-
}
|
126
|
-
/**
|
127
|
-
* @description 下载重命名
|
128
|
-
*/
|
129
|
-
function loadFileRename(fileUrl, fileName) {
|
130
|
-
var xhr = new XMLHttpRequest();
|
131
|
-
xhr.open('GET', fileUrl, true);
|
132
|
-
xhr.responseType = 'blob';
|
133
|
-
xhr.onload = function () {
|
134
|
-
if (xhr.status === 200) {
|
135
|
-
var link = document.createElement('a');
|
136
|
-
var body = document.querySelector('body');
|
137
|
-
link.href = window.URL.createObjectURL(xhr.response);
|
138
|
-
link.download = fileName;
|
139
|
-
// fix Firefox
|
140
|
-
link.style.display = 'none';
|
141
|
-
body.appendChild(link);
|
142
|
-
link.click();
|
143
|
-
body.removeChild(link);
|
144
|
-
window.URL.revokeObjectURL(link.href);
|
145
|
-
}
|
146
|
-
};
|
147
|
-
xhr.send();
|
148
|
-
}
|
149
|
-
/**
|
150
|
-
* @description 文件大小提示转换
|
151
|
-
*/
|
152
|
-
function transformFileSize(value) {
|
153
|
-
if (value < 1024) {
|
154
|
-
return round(value, 2).toFixed(2) + 'B';
|
155
|
-
}
|
156
|
-
else if (value < 1024 * 1024) {
|
157
|
-
return round(divide(value, 1024), 2).toFixed(2) + 'KB';
|
158
|
-
}
|
159
|
-
return round(divide(value, 1024, 1024), 2).toFixed(2) + 'MB';
|
160
|
-
}
|
161
|
-
/**
|
162
|
-
* @description 更具key判断前后值是否一致
|
163
|
-
*/
|
164
|
-
function isEqualByKey(keys, record, preRecord) {
|
165
|
-
var isEqual = false; // 是否相等
|
166
|
-
if (!record || !preRecord) {
|
167
|
-
isEqual = true;
|
168
|
-
return isEqual;
|
169
|
-
}
|
170
|
-
// 如果数据源相同的话,那么判断是初次更改,应该更新
|
171
|
-
if (record === preRecord) {
|
172
|
-
isEqual = true;
|
173
|
-
return isEqual;
|
174
|
-
}
|
175
|
-
for (var i = 0; i < keys.length; i++) {
|
176
|
-
var key = keys[i];
|
177
|
-
if (record[key] !== preRecord[key]) {
|
178
|
-
isEqual = true;
|
179
|
-
break;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
return isEqual;
|
183
|
-
}
|
184
|
-
|
185
|
-
var tools = /*#__PURE__*/Object.freeze({
|
186
|
-
__proto__: null,
|
187
|
-
timeTransfrom: timeTransfrom,
|
188
|
-
plus: plus,
|
189
|
-
minus: minus,
|
190
|
-
times: times,
|
191
|
-
divide: divide,
|
192
|
-
exactRound: exactRound,
|
193
|
-
toThousand: toThousand,
|
194
|
-
clearAssignStr: clearAssignStr,
|
195
|
-
loadFileRename: loadFileRename,
|
196
|
-
transformFileSize: transformFileSize,
|
197
|
-
isEqualByKey: isEqualByKey
|
198
|
-
});
|
199
|
-
|
200
|
-
export { timeTransfrom as a, toThousand as b, clearAssignStr as c, divide as d, exactRound as e, transformFileSize as f, isEqualByKey as i, loadFileRename as l, tools as t };
|
package/dist/tools-49b33116.js
DELETED
@@ -1,195 +0,0 @@
|
|
1
|
-
import { _ as __assign, a as __spreadArray } from './tslib.es6-b9033aad.js';
|
2
|
-
import dayjs from 'dayjs';
|
3
|
-
import { divide as divide$1, round, plus, minus, times } from 'number-precision';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* @description 时间格式转换
|
7
|
-
*/
|
8
|
-
function timeTransfrom(timeParams) {
|
9
|
-
var _a, _b, _c, _d, _e;
|
10
|
-
var params = timeParams.params, fromKey = timeParams.fromKey, toKey = timeParams.toKey, _f = timeParams.type, type = _f === void 0 ? 'string' : _f;
|
11
|
-
var copyParams = __assign({}, params);
|
12
|
-
for (var i = 0; i < fromKey.length; i++) {
|
13
|
-
var fromKeyItem = fromKey[i];
|
14
|
-
var toKeyItem = toKey[i];
|
15
|
-
// 从一个键转换成两个键
|
16
|
-
if (typeof fromKeyItem === 'string' && typeof toKeyItem === 'object') {
|
17
|
-
if (type === 'string' && copyParams[fromKeyItem]) {
|
18
|
-
var _g = copyParams[fromKeyItem], startMoment = _g[0], endMoment = _g[1];
|
19
|
-
var start = void 0, end = void 0;
|
20
|
-
if (dayjs.isDayjs(startMoment)) {
|
21
|
-
start = startMoment.format('YYYY-MM-DD');
|
22
|
-
}
|
23
|
-
if (dayjs.isDayjs(endMoment)) {
|
24
|
-
end = endMoment.format('YYYY-MM-DD');
|
25
|
-
}
|
26
|
-
delete copyParams[fromKeyItem];
|
27
|
-
copyParams = __assign(__assign({}, copyParams), (_a = {}, _a[toKeyItem[0]] = start, _a[toKeyItem[1]] = end, _a));
|
28
|
-
}
|
29
|
-
else {
|
30
|
-
copyParams = __assign(__assign({}, copyParams), (_b = {}, _b[toKeyItem[0]] = undefined, _b[toKeyItem[1]] = undefined, _b));
|
31
|
-
}
|
32
|
-
}
|
33
|
-
// 从一个键转换成一个键
|
34
|
-
if (typeof fromKeyItem === 'string' && typeof toKeyItem === 'string') {
|
35
|
-
if (type === 'string') {
|
36
|
-
var _dayjsObj = copyParams[fromKeyItem];
|
37
|
-
var start = void 0;
|
38
|
-
if (dayjs.isDayjs(_dayjsObj)) {
|
39
|
-
start = _dayjsObj.format('YYYY-MM-DD');
|
40
|
-
}
|
41
|
-
delete copyParams[fromKeyItem];
|
42
|
-
copyParams = __assign(__assign({}, copyParams), (_c = {}, _c[toKeyItem] = start, _c));
|
43
|
-
}
|
44
|
-
if (type === 'object') {
|
45
|
-
var start = copyParams[fromKeyItem]
|
46
|
-
? dayjs(copyParams[fromKeyItem])
|
47
|
-
: undefined;
|
48
|
-
delete copyParams[fromKeyItem];
|
49
|
-
copyParams = __assign(__assign({}, copyParams), (_d = {}, _d[toKeyItem] = start, _d));
|
50
|
-
}
|
51
|
-
}
|
52
|
-
// 从两个键转换成一个键
|
53
|
-
if (typeof fromKeyItem === 'object' && typeof toKeyItem === 'string') {
|
54
|
-
if (type === 'object') {
|
55
|
-
var startMoment = fromKeyItem[0], endMoment = fromKeyItem[1];
|
56
|
-
var intime = copyParams[toKeyItem] || [null, null];
|
57
|
-
if (copyParams[startMoment]) {
|
58
|
-
intime[0] = dayjs(copyParams[startMoment]);
|
59
|
-
delete copyParams[startMoment];
|
60
|
-
}
|
61
|
-
if (copyParams[endMoment]) {
|
62
|
-
intime[1] = dayjs(copyParams[endMoment]);
|
63
|
-
delete copyParams[endMoment];
|
64
|
-
}
|
65
|
-
copyParams = __assign(__assign({}, copyParams), (_e = {}, _e[toKeyItem] = intime, _e));
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
return copyParams;
|
70
|
-
}
|
71
|
-
function divide(num1, num2) {
|
72
|
-
var others = [];
|
73
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
74
|
-
others[_i - 2] = arguments[_i];
|
75
|
-
}
|
76
|
-
try {
|
77
|
-
return divide$1.apply(void 0, __spreadArray([num1, num2], others));
|
78
|
-
}
|
79
|
-
catch (err) {
|
80
|
-
console.log(err);
|
81
|
-
return 0;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
/**
|
85
|
-
* @description 精确四舍五入后保留几位小数
|
86
|
-
*/
|
87
|
-
function exactRound(num, ratio) {
|
88
|
-
var typeNum = typeof num;
|
89
|
-
if (typeNum !== 'number' && typeNum !== 'string') {
|
90
|
-
return num;
|
91
|
-
}
|
92
|
-
try {
|
93
|
-
return round(num, ratio).toFixed(ratio);
|
94
|
-
}
|
95
|
-
catch (err) {
|
96
|
-
console.error(err);
|
97
|
-
return num;
|
98
|
-
}
|
99
|
-
}
|
100
|
-
/**
|
101
|
-
* @description 添加千分符符号
|
102
|
-
*/
|
103
|
-
function toThousand(num) {
|
104
|
-
var typeNum = typeof num;
|
105
|
-
if (typeNum !== 'number' && typeNum !== 'string') {
|
106
|
-
return num;
|
107
|
-
}
|
108
|
-
var str = (num + '').replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,');
|
109
|
-
return str;
|
110
|
-
}
|
111
|
-
/**
|
112
|
-
* @description 去除指定字符串
|
113
|
-
*/
|
114
|
-
function clearAssignStr(str, originalStr) {
|
115
|
-
if (!originalStr) {
|
116
|
-
return originalStr;
|
117
|
-
}
|
118
|
-
if (originalStr.startsWith(str)) {
|
119
|
-
return originalStr.replace(str, '');
|
120
|
-
}
|
121
|
-
return originalStr;
|
122
|
-
}
|
123
|
-
/**
|
124
|
-
* @description 下载重命名
|
125
|
-
*/
|
126
|
-
function loadFileRename(fileUrl, fileName) {
|
127
|
-
var xhr = new XMLHttpRequest();
|
128
|
-
xhr.open('GET', fileUrl, true);
|
129
|
-
xhr.responseType = 'blob';
|
130
|
-
xhr.onload = function () {
|
131
|
-
if (xhr.status === 200) {
|
132
|
-
var link = document.createElement('a');
|
133
|
-
var body = document.querySelector('body');
|
134
|
-
link.href = window.URL.createObjectURL(xhr.response);
|
135
|
-
link.download = fileName;
|
136
|
-
// fix Firefox
|
137
|
-
link.style.display = 'none';
|
138
|
-
body.appendChild(link);
|
139
|
-
link.click();
|
140
|
-
body.removeChild(link);
|
141
|
-
window.URL.revokeObjectURL(link.href);
|
142
|
-
}
|
143
|
-
};
|
144
|
-
xhr.send();
|
145
|
-
}
|
146
|
-
/**
|
147
|
-
* @description 文件大小提示转换
|
148
|
-
*/
|
149
|
-
function transformFileSize(value) {
|
150
|
-
if (value < 1024) {
|
151
|
-
return round(value, 2).toFixed(2) + 'B';
|
152
|
-
}
|
153
|
-
else if (value < 1024 * 1024) {
|
154
|
-
return round(divide(value, 1024), 2).toFixed(2) + 'KB';
|
155
|
-
}
|
156
|
-
return round(divide(value, 1024, 1024), 2).toFixed(2) + 'MB';
|
157
|
-
}
|
158
|
-
/**
|
159
|
-
* @description 更具key判断前后值是否一致
|
160
|
-
*/
|
161
|
-
function isEqualByKey(keys, record, preRecord) {
|
162
|
-
var isEqual = false; // 是否相等
|
163
|
-
if (!record || !preRecord) {
|
164
|
-
isEqual = true;
|
165
|
-
return isEqual;
|
166
|
-
}
|
167
|
-
if (record === preRecord) {
|
168
|
-
return isEqual;
|
169
|
-
}
|
170
|
-
for (var i = 0; i < keys.length; i++) {
|
171
|
-
var key = keys[i];
|
172
|
-
if (record[key] !== preRecord[key]) {
|
173
|
-
isEqual = true;
|
174
|
-
break;
|
175
|
-
}
|
176
|
-
}
|
177
|
-
return isEqual;
|
178
|
-
}
|
179
|
-
|
180
|
-
var tools = /*#__PURE__*/Object.freeze({
|
181
|
-
__proto__: null,
|
182
|
-
timeTransfrom: timeTransfrom,
|
183
|
-
plus: plus,
|
184
|
-
minus: minus,
|
185
|
-
times: times,
|
186
|
-
divide: divide,
|
187
|
-
exactRound: exactRound,
|
188
|
-
toThousand: toThousand,
|
189
|
-
clearAssignStr: clearAssignStr,
|
190
|
-
loadFileRename: loadFileRename,
|
191
|
-
transformFileSize: transformFileSize,
|
192
|
-
isEqualByKey: isEqualByKey
|
193
|
-
});
|
194
|
-
|
195
|
-
export { timeTransfrom as a, toThousand as b, clearAssignStr as c, divide as d, exactRound as e, transformFileSize as f, isEqualByKey as i, loadFileRename as l, tools as t };
|