@haluo/util 2.0.22 → 2.0.23
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/index.d.ts +1 -3
- package/dist/index.js +61 -33
- package/dist/modules/cookie/index.js +24 -18
- package/dist/modules/date/index.js +56 -49
- package/dist/modules/dom/index.js +23 -16
- package/dist/modules/filter/index.js +25 -15
- package/dist/modules/format/index.js +12 -6
- package/dist/modules/match/index.js +10 -6
- package/dist/modules/monitor/index.js +14 -7
- package/dist/modules/monitor/lib/jsError.js +35 -39
- package/dist/modules/monitor/lib/timing.js +28 -24
- package/dist/modules/monitor/lib/xhr.js +33 -26
- package/dist/modules/monitor/utils/onload.js +4 -1
- package/dist/modules/monitor/utils/tracker.js +27 -13
- package/dist/modules/number/index.js +35 -31
- package/dist/modules/open-app/index.js +61 -66
- package/dist/modules/sentry/index.js +27 -19
- package/dist/modules/tools/index.d.ts +1 -1
- package/dist/modules/tools/index.js +169 -158
- package/dist/modules/upload/aliOss copy.d.ts +321 -0
- package/dist/modules/upload/aliOss copy.js +734 -0
- package/dist/modules/upload/aliOss.d.ts +51 -28
- package/dist/modules/upload/aliOss.js +154 -73
- package/dist/modules/upload/backup-aliOss.d.ts +321 -0
- package/dist/modules/upload/backup-aliOss.js +734 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.js +2 -1
- package/package.json +3 -16
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import match from './modules/match';
|
|
|
7
7
|
import number from './modules/number';
|
|
8
8
|
import openApp from './modules/open-app';
|
|
9
9
|
import tools from './modules/tools';
|
|
10
|
-
import upload from './modules/upload';
|
|
11
10
|
import monitor from './modules/monitor';
|
|
12
11
|
export * from './modules/monitor';
|
|
13
12
|
interface Modules {
|
|
@@ -20,7 +19,6 @@ interface Modules {
|
|
|
20
19
|
number: typeof number;
|
|
21
20
|
openApp: typeof openApp;
|
|
22
21
|
tools: typeof tools;
|
|
23
|
-
upload: typeof upload;
|
|
24
22
|
monitor: typeof monitor;
|
|
25
23
|
}
|
|
26
24
|
declare class Utils {
|
|
@@ -36,4 +34,4 @@ interface Utils extends Modules {
|
|
|
36
34
|
}
|
|
37
35
|
declare const _default: Utils;
|
|
38
36
|
export default _default;
|
|
39
|
-
export { cookie, date, dom, filter, format, match, number, openApp, tools,
|
|
37
|
+
export { cookie, date, dom, filter, format, match, number, openApp, tools, monitor };
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
format,
|
|
19
|
-
match,
|
|
20
|
-
number,
|
|
21
|
-
openApp,
|
|
22
|
-
tools,
|
|
23
|
-
upload,
|
|
24
|
-
monitor
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
18
|
};
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.monitor = exports.tools = exports.openApp = exports.number = exports.match = exports.format = exports.filter = exports.dom = exports.date = exports.cookie = void 0;
|
|
21
|
+
var cookie_1 = __importDefault(require("./modules/cookie"));
|
|
22
|
+
exports.cookie = cookie_1.default;
|
|
23
|
+
var date_1 = __importDefault(require("./modules/date"));
|
|
24
|
+
exports.date = date_1.default;
|
|
25
|
+
var dom_1 = __importDefault(require("./modules/dom"));
|
|
26
|
+
exports.dom = dom_1.default;
|
|
27
|
+
var filter_1 = __importDefault(require("./modules/filter"));
|
|
28
|
+
exports.filter = filter_1.default;
|
|
29
|
+
var format_1 = __importDefault(require("./modules/format"));
|
|
30
|
+
exports.format = format_1.default;
|
|
31
|
+
var match_1 = __importDefault(require("./modules/match"));
|
|
32
|
+
exports.match = match_1.default;
|
|
33
|
+
var number_1 = __importDefault(require("./modules/number"));
|
|
34
|
+
exports.number = number_1.default;
|
|
35
|
+
var open_app_1 = __importDefault(require("./modules/open-app"));
|
|
36
|
+
exports.openApp = open_app_1.default;
|
|
37
|
+
var tools_1 = __importDefault(require("./modules/tools"));
|
|
38
|
+
exports.tools = tools_1.default;
|
|
39
|
+
var monitor_1 = __importDefault(require("./modules/monitor"));
|
|
40
|
+
exports.monitor = monitor_1.default;
|
|
41
|
+
__exportStar(require("./modules/monitor"), exports);
|
|
42
|
+
var modules = {
|
|
43
|
+
cookie: cookie_1.default,
|
|
44
|
+
date: date_1.default,
|
|
45
|
+
dom: dom_1.default,
|
|
46
|
+
filter: filter_1.default,
|
|
47
|
+
format: format_1.default,
|
|
48
|
+
match: match_1.default,
|
|
49
|
+
number: number_1.default,
|
|
50
|
+
openApp: open_app_1.default,
|
|
51
|
+
tools: tools_1.default,
|
|
52
|
+
monitor: monitor_1.default
|
|
53
|
+
};
|
|
54
|
+
var Utils = /** @class */ (function () {
|
|
55
|
+
function Utils() {
|
|
28
56
|
Object.assign(this, modules);
|
|
29
57
|
}
|
|
30
58
|
/**
|
|
@@ -32,12 +60,12 @@ class Utils {
|
|
|
32
60
|
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
33
61
|
* @param {Object} Vue 需要挂载的目标对象
|
|
34
62
|
*/
|
|
35
|
-
install(app) {
|
|
36
|
-
Object.keys(modules).forEach((key)
|
|
37
|
-
|
|
63
|
+
Utils.prototype.install = function (app) {
|
|
64
|
+
Object.keys(modules).forEach(function (key) {
|
|
65
|
+
var globalProperties = app.config.globalProperties;
|
|
38
66
|
globalProperties['$' + key] = modules[key];
|
|
39
67
|
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
68
|
+
};
|
|
69
|
+
return Utils;
|
|
70
|
+
}());
|
|
71
|
+
exports.default = new Utils();
|
|
@@ -4,46 +4,52 @@
|
|
|
4
4
|
* @createBy: @2021.01.21
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
|
-
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
var CookieClass = /** @class */ (function () {
|
|
9
|
+
function CookieClass() {
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* 获取cookie
|
|
10
13
|
* @param {String} name
|
|
11
14
|
* @return {String}
|
|
12
15
|
*/
|
|
13
|
-
getCookie(name) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
for (
|
|
17
|
-
|
|
16
|
+
CookieClass.prototype.getCookie = function (name) {
|
|
17
|
+
var _name = name + '=';
|
|
18
|
+
var ca = document.cookie.split(';');
|
|
19
|
+
for (var i = 0; i < ca.length; i++) {
|
|
20
|
+
var c = ca[i];
|
|
18
21
|
while (c.charAt(0) === ' ')
|
|
19
22
|
c = c.substring(1);
|
|
20
23
|
if (c.includes(_name))
|
|
21
24
|
return c.substring(_name.length, c.length);
|
|
22
25
|
}
|
|
23
26
|
return '';
|
|
24
|
-
}
|
|
27
|
+
};
|
|
25
28
|
/**
|
|
26
29
|
* 设置cookie
|
|
27
30
|
* @param {Object} ICookie
|
|
28
31
|
*/
|
|
29
|
-
setCookie
|
|
32
|
+
CookieClass.prototype.setCookie = function (_a) {
|
|
33
|
+
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.exdays, exdays = _d === void 0 ? -1 : _d, _e = _a.path, path = _e === void 0 ? '/' : _e, _f = _a.domain, domain = _f === void 0 ? '.jddmoto.com' : _f;
|
|
30
34
|
var d = new Date();
|
|
31
35
|
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
32
|
-
var expires =
|
|
33
|
-
document.cookie =
|
|
34
|
-
}
|
|
36
|
+
var expires = "expires=".concat(d.toUTCString());
|
|
37
|
+
document.cookie = "".concat(name, "=").concat(value, ";").concat(expires, ";path=").concat(path, ";domain=").concat(domain, ";");
|
|
38
|
+
};
|
|
35
39
|
/**
|
|
36
40
|
* 清除Cookie
|
|
37
41
|
* @param {String} name
|
|
38
42
|
*/
|
|
39
|
-
clearCookie
|
|
43
|
+
CookieClass.prototype.clearCookie = function (_a) {
|
|
44
|
+
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.path, path = _c === void 0 ? '/' : _c, _d = _a.domain, domain = _d === void 0 ? '.jddmoto.com' : _d;
|
|
40
45
|
this.setCookie({
|
|
41
|
-
name,
|
|
46
|
+
name: name,
|
|
42
47
|
value: '',
|
|
43
48
|
exdays: -1,
|
|
44
|
-
path,
|
|
45
|
-
domain
|
|
49
|
+
path: path,
|
|
50
|
+
domain: domain
|
|
46
51
|
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
};
|
|
53
|
+
return CookieClass;
|
|
54
|
+
}());
|
|
55
|
+
exports.default = new CookieClass();
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @createBy: @2020.05.21
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
8
|
/**
|
|
8
9
|
* 格式化时间 详情内容里的时间格式
|
|
9
10
|
* @param {Object} data 格式,可参考format 中的o属性
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
function replacementDate(data, fmt) {
|
|
14
15
|
for (var k in data) {
|
|
15
16
|
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
16
|
-
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : ((
|
|
17
|
+
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00".concat(data[k])).substr(('' + data[k]).length)));
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
return fmt;
|
|
@@ -30,7 +31,9 @@ function replacementYear(date, fmt) {
|
|
|
30
31
|
}
|
|
31
32
|
return fmt;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
var DateClass = /** @class */ (function () {
|
|
35
|
+
function DateClass() {
|
|
36
|
+
}
|
|
34
37
|
/**
|
|
35
38
|
* 格式化时间
|
|
36
39
|
* @param {String|Number} date 需要格式化的时间 2017-11-11、2017/11/11、linux time
|
|
@@ -40,10 +43,11 @@ class DateClass {
|
|
|
40
43
|
* date.format(new Date(), 'YYYY:MM:DD') // 自定义格式 'YYYY:MM:DD'
|
|
41
44
|
* @return {String} fmt 'YYYY-MM-DD HH:mm:ss'
|
|
42
45
|
*/
|
|
43
|
-
format(date, fmt
|
|
46
|
+
DateClass.prototype.format = function (date, fmt) {
|
|
47
|
+
if (fmt === void 0) { fmt = 'YYYY-MM-DD HH:mm:ss'; }
|
|
44
48
|
if (!date)
|
|
45
49
|
return '';
|
|
46
|
-
|
|
50
|
+
var timeData = typeof date === 'string' ? new Date(date.replace(/-/g, '/')) : date;
|
|
47
51
|
timeData = typeof date === 'number' ? new Date(date) : timeData;
|
|
48
52
|
var o = {
|
|
49
53
|
'M+': timeData.getMonth() + 1,
|
|
@@ -55,7 +59,7 @@ class DateClass {
|
|
|
55
59
|
'q+': Math.floor((timeData.getMonth() + 3) / 3),
|
|
56
60
|
'S': timeData.getMilliseconds()
|
|
57
61
|
};
|
|
58
|
-
|
|
62
|
+
var week = {
|
|
59
63
|
'0': '\u65e5',
|
|
60
64
|
'1': '\u4e00',
|
|
61
65
|
'2': '\u4e8c',
|
|
@@ -66,10 +70,10 @@ class DateClass {
|
|
|
66
70
|
};
|
|
67
71
|
fmt = replacementYear(timeData, fmt);
|
|
68
72
|
if (/(E+)/.test(fmt)) {
|
|
69
|
-
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[
|
|
73
|
+
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week["".concat(timeData.getDay(), " ")]);
|
|
70
74
|
}
|
|
71
75
|
return replacementDate(o, fmt);
|
|
72
|
-
}
|
|
76
|
+
};
|
|
73
77
|
/**
|
|
74
78
|
* 天数加减
|
|
75
79
|
* @param {string | Date} date 传入的时间 2020-10-15 or Date
|
|
@@ -78,11 +82,11 @@ class DateClass {
|
|
|
78
82
|
* addDaysToDate('2020-10-15', -10) // '2020-10-05'
|
|
79
83
|
* @return {String} fmt 'YYYY-MM-DD'
|
|
80
84
|
*/
|
|
81
|
-
addDaysToDate(date, days) {
|
|
82
|
-
|
|
85
|
+
DateClass.prototype.addDaysToDate = function (date, days) {
|
|
86
|
+
var d = typeof date === 'object' ? date : new Date(date);
|
|
83
87
|
d.setDate(d.getDate() + days);
|
|
84
88
|
return d.toISOString().split('T')[0];
|
|
85
|
-
}
|
|
89
|
+
};
|
|
86
90
|
/**
|
|
87
91
|
* 获取倒计时剩余时间
|
|
88
92
|
* @param {Date | Number} endTime 截止时间
|
|
@@ -91,55 +95,56 @@ class DateClass {
|
|
|
91
95
|
* date.format(1586840260500) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
|
|
92
96
|
* @return {object | boolean} {dd: '天', hh: '时', mm: '分', ss: '秒'}
|
|
93
97
|
*/
|
|
94
|
-
remainTime(endTime, startTime
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
DateClass.prototype.remainTime = function (endTime, startTime) {
|
|
99
|
+
if (startTime === void 0) { startTime = new Date(); }
|
|
100
|
+
var ts = Number(endTime) - Number(startTime); // 计算剩余的毫秒数
|
|
101
|
+
var dd = Math.floor(ts / 1000 / 60 / 60 / 24); // 计算剩余的天数
|
|
102
|
+
var hh = Math.floor(ts / 1000 / 60 / 60 % 24); // 计算剩余的小时数
|
|
103
|
+
var mm = Math.floor(ts / 1000 / 60 % 60); // 计算剩余的分钟数
|
|
104
|
+
var ss = Math.floor(ts / 1000 % 60); // 计算剩余的秒数
|
|
100
105
|
if (ts <= 0)
|
|
101
106
|
return false;
|
|
102
107
|
return {
|
|
103
|
-
dd: (dd < 10 ?
|
|
104
|
-
hh: (hh < 10 ?
|
|
105
|
-
mm: (mm < 10 ?
|
|
106
|
-
ss: (ss < 10 ?
|
|
108
|
+
dd: (dd < 10 ? "0".concat(dd) : dd),
|
|
109
|
+
hh: (hh < 10 ? "0".concat(hh) : hh),
|
|
110
|
+
mm: (mm < 10 ? "0".concat(mm) : mm),
|
|
111
|
+
ss: (ss < 10 ? "0".concat(ss) : ss)
|
|
107
112
|
};
|
|
108
|
-
}
|
|
113
|
+
};
|
|
109
114
|
/**
|
|
110
115
|
* 格式化现在的已过时间
|
|
111
116
|
* @param {Number} startTime
|
|
112
117
|
* @return {String} *年前 *个月前 *天前 *小时前 *分钟前 刚刚
|
|
113
118
|
*/
|
|
114
|
-
formatPassTime(startTime) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
DateClass.prototype.formatPassTime = function (startTime) {
|
|
120
|
+
var currentTime = new Date();
|
|
121
|
+
var time = currentTime - startTime;
|
|
122
|
+
var year = Math.floor(time / (1000 * 60 * 60 * 24) / 30 / 12);
|
|
118
123
|
if (year)
|
|
119
|
-
return
|
|
120
|
-
|
|
124
|
+
return "".concat(year, "\u5E74\u524D");
|
|
125
|
+
var month = Math.floor(time / (1000 * 60 * 60 * 24) / 30);
|
|
121
126
|
if (month)
|
|
122
|
-
return
|
|
123
|
-
|
|
127
|
+
return "".concat(month, "\u4E2A\u6708\u524D");
|
|
128
|
+
var day = Math.floor(time / (1000 * 60 * 60 * 24));
|
|
124
129
|
if (day)
|
|
125
|
-
return
|
|
126
|
-
|
|
130
|
+
return "".concat(day, "\u5929\u524D");
|
|
131
|
+
var hour = Math.floor(time / (1000 * 60 * 60));
|
|
127
132
|
if (hour)
|
|
128
|
-
return
|
|
129
|
-
|
|
133
|
+
return "".concat(hour, "\u5C0F\u65F6\u524D");
|
|
134
|
+
var min = Math.floor(time / (1000 * 60));
|
|
130
135
|
if (min)
|
|
131
|
-
return
|
|
136
|
+
return "".concat(min, "\u5206\u949F\u524D");
|
|
132
137
|
else
|
|
133
138
|
return '刚刚';
|
|
134
|
-
}
|
|
139
|
+
};
|
|
135
140
|
/**
|
|
136
141
|
* 格式化时间 列表里的时间内容格式 待废弃,统一时间格式
|
|
137
142
|
* @param {Number} time 1494141000*1000
|
|
138
143
|
* @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
|
|
139
144
|
*/
|
|
140
|
-
formatPassTimeForList(time) {
|
|
145
|
+
DateClass.prototype.formatPassTimeForList = function (time) {
|
|
141
146
|
return DateClass.prototype.formatPassTimeForDetail(time, 'YYYY年MM月DD日', true);
|
|
142
|
-
}
|
|
147
|
+
};
|
|
143
148
|
/**
|
|
144
149
|
* 格式化时间 详情内容里的时间格式
|
|
145
150
|
* @param {Number} time 1494141000*1000
|
|
@@ -147,24 +152,25 @@ class DateClass {
|
|
|
147
152
|
* @param {Boolean} noYear 是否显示年
|
|
148
153
|
* @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
|
|
149
154
|
*/
|
|
150
|
-
formatPassTimeForDetail(time, fmt
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
DateClass.prototype.formatPassTimeForDetail = function (time, fmt, noYear) {
|
|
156
|
+
if (fmt === void 0) { fmt = 'YYYY-MM-DD'; }
|
|
157
|
+
var date = (typeof time === 'number') ? new Date(time) : new Date((time || '').replace(/-/g, '/'));
|
|
158
|
+
var diff = (((new Date()).getTime() - date.getTime()) / 1000);
|
|
159
|
+
var dayDiff = Math.floor(diff / 86400);
|
|
160
|
+
var isValidDate = Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
|
|
155
161
|
if (!isValidDate)
|
|
156
162
|
return '';
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
var formatDate = function () {
|
|
164
|
+
var today = new Date(date);
|
|
159
165
|
var o = {
|
|
160
166
|
'Y+': today.getFullYear(),
|
|
161
167
|
'M+': ('0' + (today.getMonth() + 1)).slice(-2),
|
|
162
168
|
'D+': ('0' + today.getDate()).slice(-2)
|
|
163
169
|
};
|
|
164
170
|
fmt = replacementYear(date, fmt);
|
|
165
|
-
|
|
171
|
+
var year = today.getFullYear();
|
|
166
172
|
if (!(new Date().getFullYear() > year) && noYear) {
|
|
167
|
-
|
|
173
|
+
var backData = replacementDate(o, fmt);
|
|
168
174
|
return backData.split('年')[1];
|
|
169
175
|
}
|
|
170
176
|
return replacementDate(o, fmt);
|
|
@@ -180,6 +186,7 @@ class DateClass {
|
|
|
180
186
|
(diff < 3600 && Math.floor(diff / 60) + '分钟前') ||
|
|
181
187
|
(diff < 7200 && '1小时前') ||
|
|
182
188
|
(diff < 86400 && Math.floor(diff / 3600) + '小时前'))) || (dayDiff < 16 && dayDiff + '天前');
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
};
|
|
190
|
+
return DateClass;
|
|
191
|
+
}());
|
|
192
|
+
exports.default = new DateClass();
|
|
@@ -4,52 +4,59 @@
|
|
|
4
4
|
* @createBy: @2021.08.17
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
|
-
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
var DomClass = /** @class */ (function () {
|
|
9
|
+
function DomClass() {
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* 创建一个子元素并添加至父节点
|
|
10
13
|
* @param {Object} { name = 'div', innerHTML = '', style = {}, parent, }
|
|
11
14
|
* @return {String}
|
|
12
15
|
*/
|
|
13
|
-
createElement
|
|
16
|
+
DomClass.prototype.createElement = function (_a) {
|
|
17
|
+
var _b = _a.name, name = _b === void 0 ? 'div' : _b, _c = _a.innerHTML, innerHTML = _c === void 0 ? '' : _c, _d = _a.style, style = _d === void 0 ? {} : _d, parent = _a.parent;
|
|
14
18
|
if (!(window && window.document)) {
|
|
15
19
|
return new Error('仅支持浏览器');
|
|
16
20
|
}
|
|
17
|
-
|
|
21
|
+
var element = document.createElement(name);
|
|
18
22
|
element.innerHTML = innerHTML;
|
|
19
|
-
Object.keys(style).map((_)
|
|
23
|
+
Object.keys(style).map(function (_) { return element.style[_] = style[_]; });
|
|
20
24
|
if (parent) {
|
|
21
|
-
|
|
25
|
+
var body = document.querySelector(parent);
|
|
22
26
|
body && body.append(element);
|
|
23
27
|
}
|
|
24
28
|
return element;
|
|
25
|
-
}
|
|
29
|
+
};
|
|
26
30
|
/**
|
|
27
31
|
* 获取文本中的url并用a标签包裹
|
|
28
32
|
* @param {Object} ICookie
|
|
29
33
|
*/
|
|
30
|
-
wrapperA(text) {
|
|
34
|
+
DomClass.prototype.wrapperA = function (text) {
|
|
31
35
|
if (!(window && window.document)) {
|
|
32
36
|
return new Error('仅支持浏览器');
|
|
33
37
|
}
|
|
34
38
|
return text.replace(/((https|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|])/g, '<a href="$1">$1</a>');
|
|
35
|
-
}
|
|
39
|
+
};
|
|
36
40
|
/**
|
|
37
41
|
* 对象转化为formdata
|
|
38
42
|
* getFormData({a: 1, b: 2})
|
|
39
43
|
* @param {Object} object
|
|
40
44
|
*/
|
|
41
|
-
getFormData(object) {
|
|
42
|
-
|
|
43
|
-
Object.keys(object).forEach(key
|
|
44
|
-
|
|
45
|
+
DomClass.prototype.getFormData = function (object) {
|
|
46
|
+
var formData = new FormData();
|
|
47
|
+
Object.keys(object).forEach(function (key) {
|
|
48
|
+
var value = object[key];
|
|
45
49
|
if (Array.isArray(value)) {
|
|
46
|
-
value.forEach((subValue, i)
|
|
50
|
+
value.forEach(function (subValue, i) {
|
|
51
|
+
return formData.append(key + "[".concat(i, "]"), subValue);
|
|
52
|
+
});
|
|
47
53
|
}
|
|
48
54
|
else {
|
|
49
55
|
formData.append(key, object[key]);
|
|
50
56
|
}
|
|
51
57
|
});
|
|
52
58
|
return formData;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
};
|
|
60
|
+
return DomClass;
|
|
61
|
+
}());
|
|
62
|
+
exports.default = new DomClass();
|
|
@@ -4,35 +4,45 @@
|
|
|
4
4
|
* @createBy: @2020.05.28
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
var date_1 = __importDefault(require("../date"));
|
|
12
|
+
var number_1 = __importDefault(require("../number"));
|
|
13
|
+
var tools_1 = __importDefault(require("../tools"));
|
|
14
|
+
var FilterClass = /** @class */ (function () {
|
|
15
|
+
function FilterClass() {
|
|
16
|
+
}
|
|
11
17
|
/**
|
|
12
18
|
* 格式化时间,示例:1586840260500 | format('YYYY-MM-DD HH:mm:ss')
|
|
13
19
|
* @param {String|Number} date
|
|
14
20
|
* @param {String} fmt 'YYYY-MM-DD HH:mm:ss'
|
|
15
21
|
* @return {String} 'YYYY-MM-DD HH:mm:ss'
|
|
16
22
|
*/
|
|
17
|
-
format(date, fmt
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
FilterClass.prototype.format = function (date, fmt) {
|
|
24
|
+
if (fmt === void 0) { fmt = 'YYYY-MM-DD HH:mm:ss'; }
|
|
25
|
+
return date_1.default.format(date, fmt);
|
|
26
|
+
};
|
|
20
27
|
/**
|
|
21
28
|
* 格式化金额,示例:123456 | formatMoney
|
|
22
29
|
* @param {Number} num
|
|
23
30
|
* @return {String} 123,456
|
|
24
31
|
*/
|
|
25
|
-
formatMoney(money) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
32
|
+
FilterClass.prototype.formatMoney = function (money) {
|
|
33
|
+
return number_1.default.formatMoney(money);
|
|
34
|
+
};
|
|
28
35
|
/**
|
|
29
36
|
* 截取数组或字符串,示例:'1234' | slice(3)
|
|
30
37
|
* @param {Array|String} target 数组或字符串
|
|
31
38
|
* @param {Number} length 截取长度,从0开始
|
|
32
39
|
* @return {any}
|
|
33
40
|
*/
|
|
34
|
-
slice
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
FilterClass.prototype.slice = function (target, length) {
|
|
42
|
+
if (target === void 0) { target = ''; }
|
|
43
|
+
if (length === void 0) { length = 0; }
|
|
44
|
+
return tools_1.default.slice(target, length);
|
|
45
|
+
};
|
|
46
|
+
return FilterClass;
|
|
47
|
+
}());
|
|
48
|
+
exports.default = new FilterClass();
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Format = /** @class */ (function () {
|
|
4
|
+
function Format() {
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* @desc 对于对象非数字与布尔值的value,当其为falsy时,转换成separator
|
|
4
8
|
* @param {object} obj 传入的对象
|
|
@@ -6,11 +10,13 @@ class Format {
|
|
|
6
10
|
* transformObjectNullVal({ a: null, b: 0}, '23') // {a: "23", b: 0}
|
|
7
11
|
* @return {object}
|
|
8
12
|
*/
|
|
9
|
-
transformObjectNullVal(obj, separator
|
|
10
|
-
|
|
13
|
+
Format.prototype.transformObjectNullVal = function (obj, separator) {
|
|
14
|
+
if (separator === void 0) { separator = '-'; }
|
|
15
|
+
return Object.keys(obj).reduce(function (cur, key) {
|
|
11
16
|
cur[key] = obj[key] || ((obj[key] === 0 || obj[key] === false) ? obj[key] : separator);
|
|
12
17
|
return cur;
|
|
13
18
|
}, {});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
};
|
|
20
|
+
return Format;
|
|
21
|
+
}());
|
|
22
|
+
exports.default = new Format();
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* @Author: wanghui
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
6
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
var MatchClass = /** @class */ (function () {
|
|
8
|
+
function MatchClass() {
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
11
|
* 根据类型返回正则
|
|
9
12
|
* @param {String} str 检测的内容
|
|
@@ -11,8 +14,8 @@ class MatchClass {
|
|
|
11
14
|
* checkType('10.120.33.11', 'ip') // true
|
|
12
15
|
* @return {Boolean} true or false
|
|
13
16
|
*/
|
|
14
|
-
checkType(str, type) {
|
|
15
|
-
|
|
17
|
+
MatchClass.prototype.checkType = function (str, type) {
|
|
18
|
+
var regexp = {
|
|
16
19
|
'ip': /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/.test(str),
|
|
17
20
|
'port': /^(\d|[1-5]\d{4}|6[1-4]\d{3}|65[1-4]\d{2}|655[1-2]\d|6553[1-5])$/.test(str),
|
|
18
21
|
'phone': /^1[3|4|5|6|7|8][0-9]{9}$/.test(str),
|
|
@@ -22,6 +25,7 @@ class MatchClass {
|
|
|
22
25
|
'url': /[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i.test(str)
|
|
23
26
|
};
|
|
24
27
|
return regexp[type];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
};
|
|
29
|
+
return MatchClass;
|
|
30
|
+
}());
|
|
31
|
+
exports.default = new MatchClass();
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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.Tracker = void 0;
|
|
7
|
+
var jsError_1 = require("./lib/jsError");
|
|
8
|
+
var xhr_1 = __importDefault(require("./lib/xhr"));
|
|
9
|
+
var tracker_1 = __importDefault(require("./utils/tracker"));
|
|
10
|
+
exports.Tracker = tracker_1.default;
|
|
4
11
|
// import timing from './lib/timing'
|
|
5
|
-
|
|
6
|
-
injectJsError(data);
|
|
7
|
-
|
|
12
|
+
function setup(data) {
|
|
13
|
+
(0, jsError_1.injectJsError)(data);
|
|
14
|
+
(0, xhr_1.default)(data);
|
|
8
15
|
}
|
|
9
|
-
|
|
16
|
+
exports.default = setup;
|
|
10
17
|
// timing()
|