@haluo/util 2.0.14 → 2.0.16
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/README.md +6 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +6 -2
- package/dist/modules/cookie/index.d.ts +27 -0
- package/dist/modules/cookie/index.js +2 -2
- package/dist/modules/date/index.d.ts +52 -0
- package/dist/modules/date/index.js +11 -11
- package/dist/modules/dom/index.d.ts +28 -0
- package/dist/modules/dom/index.js +1 -1
- package/dist/modules/filter/index.d.ts +24 -0
- package/dist/modules/format/index.d.ts +15 -0
- package/dist/modules/match/index.d.ts +12 -0
- package/dist/modules/monitor/index.d.ts +3 -0
- package/dist/modules/monitor/index.js +2 -2
- package/dist/modules/monitor/lib/jsError.d.ts +1 -0
- package/dist/modules/monitor/lib/jsError.js +2 -3
- package/dist/modules/monitor/lib/timing.d.ts +1 -0
- package/dist/modules/monitor/lib/timing.js +1 -1
- package/dist/modules/monitor/lib/xhr.d.ts +1 -0
- package/dist/modules/monitor/lib/xhr.js +1 -1
- package/dist/modules/monitor/utils/onload.d.ts +1 -0
- package/dist/modules/monitor/utils/tracker.d.ts +7 -0
- package/dist/modules/monitor/utils/tracker.js +12 -11
- package/dist/modules/number/index.d.ts +47 -0
- package/dist/modules/number/index.js +18 -3
- package/dist/modules/sentry/index.d.ts +15 -0
- package/dist/modules/tools/index.d.ts +166 -0
- package/dist/modules/tools/index.js +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1452
- package/dist/types/index.d.ts +2 -34
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import cookie from './modules/cookie';
|
|
2
|
+
import date from './modules/date';
|
|
3
|
+
import dom from './modules/dom';
|
|
4
|
+
import filter from './modules/filter';
|
|
5
|
+
import format from './modules/format';
|
|
6
|
+
import match from './modules/match';
|
|
7
|
+
import number from './modules/number';
|
|
8
|
+
import tools from './modules/tools';
|
|
9
|
+
import monitor from './modules/monitor';
|
|
10
|
+
export * from './modules/monitor';
|
|
11
|
+
interface Modules {
|
|
12
|
+
cookie: typeof cookie;
|
|
13
|
+
date: typeof date;
|
|
14
|
+
dom: typeof dom;
|
|
15
|
+
filter: typeof filter;
|
|
16
|
+
format: typeof format;
|
|
17
|
+
match: typeof match;
|
|
18
|
+
number: typeof number;
|
|
19
|
+
tools: typeof tools;
|
|
20
|
+
monitor: typeof monitor;
|
|
21
|
+
}
|
|
22
|
+
declare class Utils {
|
|
23
|
+
constructor();
|
|
24
|
+
/**
|
|
25
|
+
* 挂载各组件
|
|
26
|
+
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
27
|
+
* @param {Object} Vue 需要挂载的目标对象
|
|
28
|
+
*/
|
|
29
|
+
install(app: any): void;
|
|
30
|
+
}
|
|
31
|
+
interface Utils extends Modules {
|
|
32
|
+
}
|
|
33
|
+
declare const _default: Utils;
|
|
34
|
+
export default _default;
|
|
35
|
+
export { cookie, date, dom, filter, format, match, number, tools, monitor };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface ICookie {
|
|
2
|
+
name: string;
|
|
3
|
+
value: string;
|
|
4
|
+
exdays: number;
|
|
5
|
+
path?: string;
|
|
6
|
+
domain?: string;
|
|
7
|
+
}
|
|
8
|
+
declare class CookieClass {
|
|
9
|
+
/**
|
|
10
|
+
* 获取cookie
|
|
11
|
+
* @param {String} name
|
|
12
|
+
* @return {String}
|
|
13
|
+
*/
|
|
14
|
+
getCookie(name: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* 设置cookie
|
|
17
|
+
* @param {Object} ICookie
|
|
18
|
+
*/
|
|
19
|
+
setCookie({ name, value, exdays, path, domain, }: ICookie): void;
|
|
20
|
+
/**
|
|
21
|
+
* 清除Cookie
|
|
22
|
+
* @param {String} name
|
|
23
|
+
*/
|
|
24
|
+
clearCookie({ name, path, domain, }: ICookie): void;
|
|
25
|
+
}
|
|
26
|
+
declare const _default: CookieClass;
|
|
27
|
+
export default _default;
|
|
@@ -33,8 +33,8 @@ var CookieClass = /** @class */ (function () {
|
|
|
33
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;
|
|
34
34
|
var d = new Date();
|
|
35
35
|
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
36
|
-
var expires = "expires="
|
|
37
|
-
document.cookie = name
|
|
36
|
+
var expires = "expires=".concat(d.toUTCString());
|
|
37
|
+
document.cookie = "".concat(name, "=").concat(value, ";").concat(expires, ";path=").concat(path, ";domain=").concat(domain, ";");
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
40
|
* 清除Cookie
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
declare class DateClass {
|
|
2
|
+
/**
|
|
3
|
+
* 格式化时间
|
|
4
|
+
* @param {String|Number} date 需要格式化的时间 2017-11-11、2017/11/11、linux time
|
|
5
|
+
* @param {String} fmt 想要格式化的格式 'YYYY-MM-DD HH:mm:ss'、'YYYY-MM-DD'、'YYYY年MM月DD日 HH时mm分ss秒'、'YYYY年MM月DD日'
|
|
6
|
+
* date.format(new Date()) // 默认格式 'YYYY-MM-DD HH:mm:ss'
|
|
7
|
+
* date.format(1586840260500) // 默认格式,传参为linux时间
|
|
8
|
+
* date.format(new Date(), 'YYYY:MM:DD') // 自定义格式 'YYYY:MM:DD'
|
|
9
|
+
* @return {String} fmt 'YYYY-MM-DD HH:mm:ss'
|
|
10
|
+
*/
|
|
11
|
+
format(date: string | number, fmt?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* 天数加减
|
|
14
|
+
* @param {string | Date} date 传入的时间 2020-10-15 or Date
|
|
15
|
+
* @param {String} days 天数
|
|
16
|
+
* addDaysToDate('2020-10-15', 10) // '2020-10-25'
|
|
17
|
+
* addDaysToDate('2020-10-15', -10) // '2020-10-05'
|
|
18
|
+
* @return {String} fmt 'YYYY-MM-DD'
|
|
19
|
+
*/
|
|
20
|
+
addDaysToDate(date: string | Date, days: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* 获取倒计时剩余时间
|
|
23
|
+
* @param {Date | Number} endTime 截止时间
|
|
24
|
+
* @param {Date | Number} startTime 开始时间,默认取客户端当前时间
|
|
25
|
+
* date.format(new Date()) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
|
|
26
|
+
* date.format(1586840260500) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
|
|
27
|
+
* @return {object | boolean} {dd: '天', hh: '时', mm: '分', ss: '秒'}
|
|
28
|
+
*/
|
|
29
|
+
remainTime(endTime: Date | Number, startTime?: Date | Number): object | boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 格式化现在的已过时间
|
|
32
|
+
* @param {Number} startTime
|
|
33
|
+
* @return {String} *年前 *个月前 *天前 *小时前 *分钟前 刚刚
|
|
34
|
+
*/
|
|
35
|
+
formatPassTime(startTime: any): string;
|
|
36
|
+
/**
|
|
37
|
+
* 格式化时间 列表里的时间内容格式 待废弃,统一时间格式
|
|
38
|
+
* @param {Number} time 1494141000*1000
|
|
39
|
+
* @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
|
|
40
|
+
*/
|
|
41
|
+
formatPassTimeForList(time: string): string | false;
|
|
42
|
+
/**
|
|
43
|
+
* 格式化时间 详情内容里的时间格式
|
|
44
|
+
* @param {Number} time 1494141000*1000
|
|
45
|
+
* @param {String} fmt 想要格式化的格式
|
|
46
|
+
* @param {Boolean} noYear 是否显示年
|
|
47
|
+
* @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
|
|
48
|
+
*/
|
|
49
|
+
formatPassTimeForDetail(time: string, fmt: string | undefined, noYear: Boolean): string | false;
|
|
50
|
+
}
|
|
51
|
+
declare const _default: DateClass;
|
|
52
|
+
export default _default;
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
function replacementDate(data, fmt) {
|
|
15
15
|
for (var k in data) {
|
|
16
16
|
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
17
|
-
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00"
|
|
17
|
+
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00".concat(data[k])).substr(('' + data[k]).length)));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
return fmt;
|
|
@@ -70,7 +70,7 @@ var DateClass = /** @class */ (function () {
|
|
|
70
70
|
};
|
|
71
71
|
fmt = replacementYear(timeData, fmt);
|
|
72
72
|
if (/(E+)/.test(fmt)) {
|
|
73
|
-
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[timeData.getDay()
|
|
73
|
+
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week["".concat(timeData.getDay(), " ")]);
|
|
74
74
|
}
|
|
75
75
|
return replacementDate(o, fmt);
|
|
76
76
|
};
|
|
@@ -105,10 +105,10 @@ var DateClass = /** @class */ (function () {
|
|
|
105
105
|
if (ts <= 0)
|
|
106
106
|
return false;
|
|
107
107
|
return {
|
|
108
|
-
dd: (dd < 10 ? "0"
|
|
109
|
-
hh: (hh < 10 ? "0"
|
|
110
|
-
mm: (mm < 10 ? "0"
|
|
111
|
-
ss: (ss < 10 ? "0"
|
|
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)
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
@@ -121,19 +121,19 @@ var DateClass = /** @class */ (function () {
|
|
|
121
121
|
var time = currentTime - startTime;
|
|
122
122
|
var year = Math.floor(time / (1000 * 60 * 60 * 24) / 30 / 12);
|
|
123
123
|
if (year)
|
|
124
|
-
return year
|
|
124
|
+
return "".concat(year, "\u5E74\u524D");
|
|
125
125
|
var month = Math.floor(time / (1000 * 60 * 60 * 24) / 30);
|
|
126
126
|
if (month)
|
|
127
|
-
return month
|
|
127
|
+
return "".concat(month, "\u4E2A\u6708\u524D");
|
|
128
128
|
var day = Math.floor(time / (1000 * 60 * 60 * 24));
|
|
129
129
|
if (day)
|
|
130
|
-
return day
|
|
130
|
+
return "".concat(day, "\u5929\u524D");
|
|
131
131
|
var hour = Math.floor(time / (1000 * 60 * 60));
|
|
132
132
|
if (hour)
|
|
133
|
-
return hour
|
|
133
|
+
return "".concat(hour, "\u5C0F\u65F6\u524D");
|
|
134
134
|
var min = Math.floor(time / (1000 * 60));
|
|
135
135
|
if (min)
|
|
136
|
-
return min
|
|
136
|
+
return "".concat(min, "\u5206\u949F\u524D");
|
|
137
137
|
else
|
|
138
138
|
return '刚刚';
|
|
139
139
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IObjectKey } from '../../types/index';
|
|
2
|
+
interface IDom {
|
|
3
|
+
name: string;
|
|
4
|
+
innerHTML?: string;
|
|
5
|
+
style?: IObjectKey<string>;
|
|
6
|
+
parent?: string;
|
|
7
|
+
}
|
|
8
|
+
declare class DomClass {
|
|
9
|
+
/**
|
|
10
|
+
* 创建一个子元素并添加至父节点
|
|
11
|
+
* @param {Object} { name = 'div', innerHTML = '', style = {}, parent, }
|
|
12
|
+
* @return {String}
|
|
13
|
+
*/
|
|
14
|
+
createElement({ name, innerHTML, style, parent, }: IDom): any;
|
|
15
|
+
/**
|
|
16
|
+
* 获取文本中的url并用a标签包裹
|
|
17
|
+
* @param {Object} ICookie
|
|
18
|
+
*/
|
|
19
|
+
wrapperA(text: string): string | Error;
|
|
20
|
+
/**
|
|
21
|
+
* 对象转化为formdata
|
|
22
|
+
* getFormData({a: 1, b: 2})
|
|
23
|
+
* @param {Object} object
|
|
24
|
+
*/
|
|
25
|
+
getFormData(object: IObjectKey<any>): FormData;
|
|
26
|
+
}
|
|
27
|
+
declare const _default: DomClass;
|
|
28
|
+
export default _default;
|
|
@@ -48,7 +48,7 @@ var DomClass = /** @class */ (function () {
|
|
|
48
48
|
var value = object[key];
|
|
49
49
|
if (Array.isArray(value)) {
|
|
50
50
|
value.forEach(function (subValue, i) {
|
|
51
|
-
return formData.append(key +
|
|
51
|
+
return formData.append(key + "[".concat(i, "]"), subValue);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare class FilterClass {
|
|
2
|
+
/**
|
|
3
|
+
* 格式化时间,示例:1586840260500 | format('YYYY-MM-DD HH:mm:ss')
|
|
4
|
+
* @param {String|Number} date
|
|
5
|
+
* @param {String} fmt 'YYYY-MM-DD HH:mm:ss'
|
|
6
|
+
* @return {String} 'YYYY-MM-DD HH:mm:ss'
|
|
7
|
+
*/
|
|
8
|
+
format(date: string | number, fmt?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* 格式化金额,示例:123456 | formatMoney
|
|
11
|
+
* @param {Number} num
|
|
12
|
+
* @return {String} 123,456
|
|
13
|
+
*/
|
|
14
|
+
formatMoney(money: number | string): string;
|
|
15
|
+
/**
|
|
16
|
+
* 截取数组或字符串,示例:'1234' | slice(3)
|
|
17
|
+
* @param {Array|String} target 数组或字符串
|
|
18
|
+
* @param {Number} length 截取长度,从0开始
|
|
19
|
+
* @return {any}
|
|
20
|
+
*/
|
|
21
|
+
slice(target?: Array<any> | string, length?: number): string | any[];
|
|
22
|
+
}
|
|
23
|
+
declare const _default: FilterClass;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface Obj {
|
|
2
|
+
[prop: string]: any;
|
|
3
|
+
}
|
|
4
|
+
declare class Format {
|
|
5
|
+
/**
|
|
6
|
+
* @desc 对于对象非数字与布尔值的value,当其为falsy时,转换成separator
|
|
7
|
+
* @param {object} obj 传入的对象
|
|
8
|
+
* @param {string} separator 替换后的值
|
|
9
|
+
* transformObjectNullVal({ a: null, b: 0}, '23') // {a: "23", b: 0}
|
|
10
|
+
* @return {object}
|
|
11
|
+
*/
|
|
12
|
+
transformObjectNullVal<T extends Obj>(obj: T, separator?: string): T;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: Format;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare class MatchClass {
|
|
2
|
+
/**
|
|
3
|
+
* 根据类型返回正则
|
|
4
|
+
* @param {String} str 检测的内容
|
|
5
|
+
* @param {String} type 检测类型
|
|
6
|
+
* checkType('10.120.33.11', 'ip') // true
|
|
7
|
+
* @return {Boolean} true or false
|
|
8
|
+
*/
|
|
9
|
+
checkType(str: string, type: string): boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: MatchClass;
|
|
12
|
+
export default _default;
|
|
@@ -10,8 +10,8 @@ var tracker_1 = __importDefault(require("./utils/tracker"));
|
|
|
10
10
|
exports.Tracker = tracker_1.default;
|
|
11
11
|
// import timing from './lib/timing'
|
|
12
12
|
function setup(data) {
|
|
13
|
-
jsError_1.injectJsError(data);
|
|
14
|
-
xhr_1.default(data);
|
|
13
|
+
(0, jsError_1.injectJsError)(data);
|
|
14
|
+
(0, xhr_1.default)(data);
|
|
15
15
|
}
|
|
16
16
|
exports.default = setup;
|
|
17
17
|
// timing()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function injectJsError(data?: any): void;
|
|
@@ -25,7 +25,7 @@ function injectJsError(data) {
|
|
|
25
25
|
));
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'jsError', message: e.message, filename: e.filename, position: e.lineno
|
|
28
|
+
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'jsError', message: e.message, filename: e.filename, position: "".concat(e.lineno, ":").concat(e.colno), reason: e.error.stack }, data
|
|
29
29
|
// selector: lastEvent ? get
|
|
30
30
|
));
|
|
31
31
|
}, true);
|
|
@@ -45,8 +45,7 @@ function injectJsError(data) {
|
|
|
45
45
|
message = reason.message;
|
|
46
46
|
stack = reason.stack;
|
|
47
47
|
}
|
|
48
|
-
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'promiseError', message: message,
|
|
49
|
-
filename: filename, position: line + ":" + column, reason: stack }, data
|
|
48
|
+
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'promiseError', message: message, filename: filename, position: "".concat(line, ":").concat(column), reason: stack }, data
|
|
50
49
|
// selector: lastEvent ? get
|
|
51
50
|
));
|
|
52
51
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function timing(): void;
|
|
@@ -35,7 +35,7 @@ function timing() {
|
|
|
35
35
|
}
|
|
36
36
|
observer.disconnect(); // 不再观察
|
|
37
37
|
}).observe({ type: 'first-input', buffered: true }); // 观察页面中最大的元素
|
|
38
|
-
onload_1.default(function () {
|
|
38
|
+
(0, onload_1.default)(function () {
|
|
39
39
|
setTimeout(function () {
|
|
40
40
|
console.dir(window.performance);
|
|
41
41
|
var _a = performance.getEntriesByType('navigation')[0], fetchStart = _a.fetchStart, connectStart = _a.connectStart, connectEnd = _a.connectEnd, requestStart = _a.requestStart, responseStart = _a.responseStart, responseEnd = _a.responseEnd, domInteractive = _a.domInteractive, domContentLoadedEventStart = _a.domContentLoadedEventStart, domContentLoadedEventEnd = _a.domContentLoadedEventEnd, loadEventStart = _a.loadEventStart;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function injectXHR(data?: any): void;
|
|
@@ -36,7 +36,7 @@ function injectXHR(data) {
|
|
|
36
36
|
var duration = Date.now() - startTime_1;
|
|
37
37
|
var status = _this.status;
|
|
38
38
|
var statusText = _this.statusText;
|
|
39
|
-
tracker_1.default.send(__assign({ kind: 'stability', type: 'xhr', eventType: event.type, pathname: _this.logData.url, status: status + '-' + statusText, duration: duration, response: _this.response ? JSON.stringify(_this.response) : '', params: body || '', title: 'xhr', reason: status + '-' + statusText +
|
|
39
|
+
tracker_1.default.send(__assign({ kind: 'stability', type: 'xhr', eventType: event.type, pathname: _this.logData.url, status: status + '-' + statusText, duration: duration, response: _this.response ? JSON.stringify(_this.response) : '', params: body || '', title: 'xhr', reason: status + '-' + statusText + " ".concat(_this.logData.url, " ").concat(_this.response ? JSON.stringify(_this.response) : '') }, data));
|
|
40
40
|
}; };
|
|
41
41
|
this.addEventListener('load', handler('load'), false);
|
|
42
42
|
this.addEventListener('error', handler('error'), false);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function onload(cb: any): void;
|
|
@@ -33,17 +33,17 @@ var SendTracker = /** @class */ (function () {
|
|
|
33
33
|
formBody.push(encodedKey + "=" + encodedValue);
|
|
34
34
|
}
|
|
35
35
|
formBody = formBody.join("&");
|
|
36
|
-
fetch('https://apm-collect.58moto.com/app/collect/original/info/report/v2', {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}).then(
|
|
43
|
-
|
|
44
|
-
}).catch(
|
|
45
|
-
|
|
46
|
-
})
|
|
36
|
+
// fetch('https://apm-collect.58moto.com/app/collect/original/info/report/v2', {
|
|
37
|
+
// method: 'POST',
|
|
38
|
+
// headers: {
|
|
39
|
+
// "Content-Type":"application/x-www-form-urlencoded"
|
|
40
|
+
// },
|
|
41
|
+
// body: formBody,
|
|
42
|
+
// }).then(res => {
|
|
43
|
+
// // console.log(res)
|
|
44
|
+
// }).catch((e) => {
|
|
45
|
+
// console.log(e)
|
|
46
|
+
// })
|
|
47
47
|
};
|
|
48
48
|
return SendTracker;
|
|
49
49
|
}());
|
|
@@ -57,6 +57,7 @@ function getExtraData() {
|
|
|
57
57
|
title: '',
|
|
58
58
|
frontStatus: 3,
|
|
59
59
|
occurTimeStamp: Date.now(),
|
|
60
|
+
// userAgent: new Parser().getResult()
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
exports.default = new SendTracker();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
declare class NumberClass {
|
|
2
|
+
/**
|
|
3
|
+
* 个位数前面补0
|
|
4
|
+
* @param {Number} num 需要格式化的数字
|
|
5
|
+
* @return {String} '01'
|
|
6
|
+
*/
|
|
7
|
+
formatNumber(num: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* 将手机号中间部分替换为星号
|
|
10
|
+
* @param {String} phone 手机号码
|
|
11
|
+
* @return {String} 131****1111
|
|
12
|
+
*/
|
|
13
|
+
formatPhone(phone: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* 格式化数字 万
|
|
16
|
+
* @param {Number} num
|
|
17
|
+
* @return {String} 12.3万
|
|
18
|
+
*/
|
|
19
|
+
convertToWan(num: number): string | number;
|
|
20
|
+
/**
|
|
21
|
+
* 格式化数字 k
|
|
22
|
+
* @param {Number} num
|
|
23
|
+
* @return {String} 1.2k
|
|
24
|
+
*/
|
|
25
|
+
convertToThousand(num: number): string | number;
|
|
26
|
+
/**
|
|
27
|
+
* 随机数,指定范围
|
|
28
|
+
* @param {Number} min 开始
|
|
29
|
+
* @param {Number} max 结束
|
|
30
|
+
* @return {Number|Object}
|
|
31
|
+
*/
|
|
32
|
+
random(min: number, max: number): number | null;
|
|
33
|
+
/**
|
|
34
|
+
* 格式化金额
|
|
35
|
+
* @param {Number} num
|
|
36
|
+
* @return {String} 123,456
|
|
37
|
+
*/
|
|
38
|
+
formatMoney(money: number | string, signal?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* 格式化手机号
|
|
41
|
+
* @param {string} number 手机号
|
|
42
|
+
* @returns {string} 格式化后的手机号 12345678901 -> 123 4567 8901
|
|
43
|
+
*/
|
|
44
|
+
formatPhoneNumber(number: string | number): string;
|
|
45
|
+
}
|
|
46
|
+
declare const _default: NumberClass;
|
|
47
|
+
export default _default;
|
|
@@ -92,12 +92,27 @@ var NumberClass = /** @class */ (function () {
|
|
|
92
92
|
var price = money.split('.')[0] + '';
|
|
93
93
|
var pricePoint = money.split('.')[1];
|
|
94
94
|
result = price.length > 6 ?
|
|
95
|
-
""
|
|
95
|
+
"".concat(price.substring(0, price.length - 6)).concat(signal).concat(price.substring(price.length - 6, price.length - 3), ",").concat(price.substring(price.length - 3, price.length))
|
|
96
96
|
:
|
|
97
|
-
""
|
|
98
|
-
result = pricePoint ? ""
|
|
97
|
+
"".concat(price.substring(0, price.length - 3)).concat(signal).concat(price.substring(price.length - 3, price.length));
|
|
98
|
+
result = pricePoint ? "".concat(result).concat(signal).concat(pricePoint) : result;
|
|
99
99
|
return result;
|
|
100
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* 格式化手机号
|
|
103
|
+
* @param {string} number 手机号
|
|
104
|
+
* @returns {string} 格式化后的手机号 12345678901 -> 123 4567 8901
|
|
105
|
+
*/
|
|
106
|
+
NumberClass.prototype.formatPhoneNumber = function (number) {
|
|
107
|
+
var numStr = String(number).replace(/\s/g, '');
|
|
108
|
+
if (numStr.length < 11) {
|
|
109
|
+
return numStr;
|
|
110
|
+
}
|
|
111
|
+
var firstPart = numStr.slice(0, 3);
|
|
112
|
+
var secondPart = numStr.slice(3, 7);
|
|
113
|
+
var thirdPart = numStr.slice(7, 11);
|
|
114
|
+
return "".concat(firstPart, " ").concat(secondPart, " ").concat(thirdPart);
|
|
115
|
+
};
|
|
101
116
|
return NumberClass;
|
|
102
117
|
}());
|
|
103
118
|
exports.default = new NumberClass();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare class Report {
|
|
2
|
+
static instance: any;
|
|
3
|
+
constructor(Vue: Object, options?: {});
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
static getInstance(Vue: Object, Option: Object): any;
|
|
6
|
+
install(): void;
|
|
7
|
+
/**
|
|
8
|
+
* 主动上报
|
|
9
|
+
* @param {String} data
|
|
10
|
+
* @param {String} type 'info','warning','error'
|
|
11
|
+
* @param {Object} options
|
|
12
|
+
*/
|
|
13
|
+
log(data?: any, type?: any, options?: any): void;
|
|
14
|
+
}
|
|
15
|
+
export default Report;
|