@haluo/util 0.0.12 → 1.0.3

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.
Files changed (45) hide show
  1. package/package.json +2 -1
  2. package/.babelrc +0 -21
  3. package/.eslintrc.js +0 -216
  4. package/__tests__/unit/date/date.spec.js +0 -14
  5. package/__tests__/unit/jest.conf.js +0 -25
  6. package/__tests__/unit/specs/date.test.js +0 -11
  7. package/coverage/clover.xml +0 -78
  8. package/coverage/coverage-final.json +0 -2
  9. package/coverage/lcov-report/base.css +0 -224
  10. package/coverage/lcov-report/block-navigation.js +0 -79
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +0 -111
  13. package/coverage/lcov-report/index.ts.html +0 -668
  14. package/coverage/lcov-report/prettify.css +0 -1
  15. package/coverage/lcov-report/prettify.js +0 -2
  16. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/coverage/lcov-report/sorter.js +0 -170
  18. package/coverage/lcov.info +0 -170
  19. package/dist/index.js +0 -36
  20. package/dist/modules/cookie/index.js +0 -54
  21. package/dist/modules/date/index.js +0 -192
  22. package/dist/modules/dom/index.js +0 -62
  23. package/dist/modules/filter/index.js +0 -57
  24. package/dist/modules/format/index.js +0 -21
  25. package/dist/modules/match/index.js +0 -31
  26. package/dist/modules/number/index.js +0 -102
  27. package/dist/modules/sentry/index.js +0 -81
  28. package/dist/modules/tools/index.js +0 -393
  29. package/global.d.ts +0 -0
  30. package/publish.sh +0 -11
  31. package/specification/CSS.md +0 -25
  32. package/specification/JS.md +0 -9
  33. package/specification/VUE.md +0 -1
  34. package/src/consts/httpCode.js +0 -10
  35. package/src/index.ts +0 -54
  36. package/src/modules/cookie/index.ts +0 -69
  37. package/src/modules/date/index.ts +0 -196
  38. package/src/modules/dom/index.ts +0 -78
  39. package/src/modules/filter/index.ts +0 -57
  40. package/src/modules/format/index.ts +0 -19
  41. package/src/modules/match/index.ts +0 -31
  42. package/src/modules/number/index.ts +0 -108
  43. package/src/modules/sentry/index.ts +0 -82
  44. package/src/modules/tools/index.ts +0 -427
  45. package/tsconfig.json +0 -34
@@ -1,196 +0,0 @@
1
- /**
2
- * @file date 格式化
3
- * @Author: wanghui
4
- * @createBy: @2020.05.21
5
- */
6
- 'use strict'
7
-
8
- import { IObjectKey } from '../../types/index'
9
-
10
- /**
11
- * 格式化时间 详情内容里的时间格式
12
- * @param {Object} data 格式,可参考format 中的o属性
13
- * @param {String} fmt 想要格式化的格式 'YYYY-MM-DD HH:mm:ss'、'YYYY-MM-DD'、'YYYY年MM月DD日 HH时mm分ss秒'、'YYYY年MM月DD日'
14
- * @return 返回fmt 格式 时间
15
- */
16
- function replacementDate(data: IObjectKey<any>, fmt: string) {
17
- for (var k in data) {
18
- if (new RegExp('(' + k + ')').test(fmt)) {
19
- fmt = fmt.replace(RegExp.$1,
20
- (RegExp.$1.length === 1) ? (data[k]) : ((`00${data[k]}`).substr(('' + data[k]).length))
21
- )
22
- }
23
- }
24
- return fmt
25
- }
26
-
27
- /**
28
- * 格式化年份
29
- * @param {String} date Date 格式
30
- * @param {String} fmt 想要格式化的格式 'YYYY-MM-DD HH:mm:ss'、'YYYY-MM-DD'、'YYYY年MM月DD日 HH时mm分ss秒'、'YYYY年MM月DD日'
31
- * @return 仅返回年份
32
- */
33
- function replacementYear(date: Date, fmt: string) {
34
- if (/(Y+)/.test(fmt)) {
35
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
36
- }
37
- return fmt
38
- }
39
-
40
- class DateClass {
41
- /**
42
- * 格式化时间
43
- * @param {String|Number} date 需要格式化的时间 2017-11-11、2017/11/11、linux time
44
- * @param {String} fmt 想要格式化的格式 'YYYY-MM-DD HH:mm:ss'、'YYYY-MM-DD'、'YYYY年MM月DD日 HH时mm分ss秒'、'YYYY年MM月DD日'
45
- * date.format(new Date()) // 默认格式 'YYYY-MM-DD HH:mm:ss'
46
- * date.format(1586840260500) // 默认格式,传参为linux时间
47
- * date.format(new Date(), 'YYYY:MM:DD') // 自定义格式 'YYYY:MM:DD'
48
- * @return {String} fmt 'YYYY-MM-DD HH:mm:ss'
49
- */
50
- format(date: string, fmt: string = 'YYYY-MM-DD HH:mm:ss') {
51
- if (!date) return ''
52
- let timeData: any = typeof date === 'string' ? new Date(date.replace(/-/g, '/')) : date
53
- timeData = typeof date === 'number' ? new Date(date) : timeData
54
- var o: IObjectKey<number> = {
55
- 'M+': timeData.getMonth() + 1,
56
- 'D+': timeData.getDate(),
57
- 'h+': timeData.getHours() % 12 === 0 ? 12 : timeData.getHours() % 12,
58
- 'H+': timeData.getHours(),
59
- 'm+': timeData.getMinutes(),
60
- 's+': timeData.getSeconds(),
61
- 'q+': Math.floor((timeData.getMonth() + 3) / 3),
62
- 'S': timeData.getMilliseconds()
63
- }
64
-
65
- const week: IObjectKey<string> = {
66
- '0': '\u65e5',
67
- '1': '\u4e00',
68
- '2': '\u4e8c',
69
- '3': '\u4e09',
70
- '4': '\u56db',
71
- '5': '\u4e94',
72
- '6': '\u516d'
73
- }
74
-
75
- fmt = replacementYear(timeData, fmt)
76
- if (/(E+)/.test(fmt)) {
77
- fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[`${timeData.getDay()} `])
78
- }
79
- return replacementDate(o, fmt)
80
- }
81
-
82
- /**
83
- * 天数加减
84
- * @param {string | Date} date 传入的时间 2020-10-15 or Date
85
- * @param {String} days 天数
86
- * addDaysToDate('2020-10-15', 10) // '2020-10-25'
87
- * addDaysToDate('2020-10-15', -10) // '2020-10-05'
88
- * @return {String} fmt 'YYYY-MM-DD'
89
- */
90
- addDaysToDate(date: string | Date, days: number) {
91
- const d = typeof date === 'object' ? date : new Date(date)
92
- d.setDate(d.getDate() + days)
93
- return d.toISOString().split('T')[0]
94
- }
95
-
96
- /**
97
- * 获取倒计时剩余时间
98
- * @param {Date | Number} endTime 截止时间
99
- * @param {Date | Number} startTime 开始时间,默认取客户端当前时间
100
- * date.format(new Date()) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
101
- * date.format(1586840260500) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
102
- * @return {object | boolean} {dd: '天', hh: '时', mm: '分', ss: '秒'}
103
- */
104
- remainTime(endTime: Date | Number, startTime: Date | Number = new Date()) : object | boolean {
105
- const ts: number = Number(endTime) - Number(startTime) // 计算剩余的毫秒数
106
- let dd = Math.floor(ts / 1000 / 60 / 60 / 24) // 计算剩余的天数
107
- let hh = Math.floor(ts / 1000 / 60 / 60 % 24) // 计算剩余的小时数
108
- let mm = Math.floor(ts / 1000 / 60 % 60) // 计算剩余的分钟数
109
- let ss = Math.floor(ts / 1000 % 60) // 计算剩余的秒数
110
- if (ts <= 0) return false
111
- return {
112
- dd: (dd < 10 ? `0${dd}` : dd),
113
- hh: (hh < 10 ? `0${hh}` : hh),
114
- mm: (mm < 10 ? `0${mm}` : mm),
115
- ss: (ss < 10 ? `0${ss}` : ss)
116
- }
117
- }
118
-
119
- /**
120
- * 格式化现在的已过时间
121
- * @param {Number} startTime
122
- * @return {String} *年前 *个月前 *天前 *小时前 *分钟前 刚刚
123
- */
124
- formatPassTime(startTime: any) {
125
- const currentTime: any = new Date();
126
- const time: any = currentTime - startTime;
127
- const year = Math.floor(time / (1000 * 60 * 60 * 24) / 30 / 12);
128
- if (year) return `${year}年前`;
129
- const month = Math.floor(time / (1000 * 60 * 60 * 24) / 30);
130
- if (month) return `${month}个月前`;
131
- const day = Math.floor(time / (1000 * 60 * 60 * 24));
132
- if (day) return `${day}天前`;
133
- const hour = Math.floor(time / (1000 * 60 * 60));
134
- if (hour) return `${hour}小时前`;
135
- const min = Math.floor(time / (1000 * 60))
136
- if (min) return `${min}分钟前`;
137
- else return '刚刚';
138
- }
139
-
140
- /**
141
- * 格式化时间 列表里的时间内容格式 待废弃,统一时间格式
142
- * @param {Number} time 1494141000*1000
143
- * @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
144
- */
145
- formatPassTimeForList(time: string) {
146
- return DateClass.prototype.formatPassTimeForDetail(time, 'YYYY年MM月DD日', true)
147
- }
148
-
149
- /**
150
- * 格式化时间 详情内容里的时间格式
151
- * @param {Number} time 1494141000*1000
152
- * @param {String} fmt 想要格式化的格式
153
- * @param {Boolean} noYear 是否显示年
154
- * @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
155
- */
156
- formatPassTimeForDetail(time: string, fmt: string = 'YYYY-MM-DD', noYear: Boolean) {
157
- const date = (typeof time === 'number') ? new Date(time) : new Date((time || '').replace(/-/g, '/'));
158
- const diff = (((new Date()).getTime() - date.getTime()) / 1000);
159
- const dayDiff = Math.floor(diff / 86400);
160
- const isValidDate = Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
161
-
162
- if (!isValidDate) return '';
163
-
164
- const formatDate = function () {
165
- const today = new Date(date);
166
- var o: IObjectKey<string | number> = {
167
- 'Y+': today.getFullYear(),
168
- 'M+': ('0' + (today.getMonth() + 1)).slice(-2),
169
- 'D+': ('0' + today.getDate()).slice(-2)
170
- };
171
- fmt = replacementYear(date, fmt)
172
- const year = today.getFullYear();
173
-
174
- if (!(new Date().getFullYear() > year) && noYear) {
175
- const backData = replacementDate(o, fmt);
176
- return backData.split('年')[1];
177
- }
178
- return replacementDate(o, fmt);
179
- };
180
-
181
- if (dayDiff === -1) {
182
- return '刚刚';
183
- } else if (isNaN(dayDiff) || dayDiff < 0 || dayDiff >= 15) {
184
- return formatDate();
185
- }
186
-
187
- return (dayDiff === 0 && (
188
- (diff < 60 && '刚刚') ||
189
- (diff < 120 && '1分钟前') ||
190
- (diff < 3600 && Math.floor(diff / 60) + '分钟前') ||
191
- (diff < 7200 && '1小时前') ||
192
- (diff < 86400 && Math.floor(diff / 3600) + '小时前'))) || (dayDiff < 16 && dayDiff + '天前');
193
- }
194
- }
195
-
196
- module.exports = new DateClass()
@@ -1,78 +0,0 @@
1
- /**
2
- * @file Cookie
3
- * @Author: wanghui
4
- * @createBy: @2021.08.17
5
- */
6
- 'use strict'
7
-
8
- import { IObjectKey } from '../../types/index'
9
-
10
- interface IDom {
11
- name: string,
12
- innerHTML?: string,
13
- style?: IObjectKey<string>,
14
- parent?: string,
15
- }
16
-
17
- class DomClass {
18
- /**
19
- * 创建一个子元素并添加至父节点
20
- * @param {Object} { name = 'div', innerHTML = '', style = {}, parent, }
21
- * @return {String}
22
- */
23
- createElement({
24
- name = 'div',
25
- innerHTML = '',
26
- style = {},
27
- parent,
28
- }: IDom) {
29
- if (!(window && window.document)) {
30
- return new Error('仅支持浏览器')
31
- }
32
-
33
- const element: any = document.createElement(name)
34
-
35
- element.innerHTML = innerHTML
36
- Object.keys(style).map((_: string) => element.style[_] = style[_])
37
- if (parent) {
38
- const body = document.querySelector(parent)
39
- body && body.append(element)
40
- }
41
- return element
42
- }
43
-
44
- /**
45
- * 获取文本中的url并用a标签包裹
46
- * @param {Object} ICookie
47
- */
48
- wrapperA(text: string) {
49
- if (!(window && window.document)) {
50
- return new Error('仅支持浏览器')
51
- }
52
-
53
- return text.replace(/((https|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|])/g, '<a href="$1">$1</a>')
54
- }
55
-
56
- /**
57
- * 对象转化为formdata
58
- * getFormData({a: 1, b: 2})
59
- * @param {Object} object
60
- */
61
- getFormData(object: IObjectKey<any>) {
62
- const formData = new FormData()
63
- Object.keys(object).forEach(key => {
64
- const value = object[key]
65
- if (Array.isArray(value)) {
66
- value.forEach((subValue, i) =>
67
- formData.append(key + `[${i}]`, subValue)
68
- )
69
- } else {
70
- formData.append(key, object[key])
71
- }
72
- })
73
- return formData
74
- }
75
- }
76
-
77
- module.exports = new DomClass()
78
-
@@ -1,57 +0,0 @@
1
- /**
2
- * @file 过滤器
3
- * @Author: wanghui
4
- * @createBy: @2020.05.28
5
- */
6
- /**
7
- * 示例:注入所有过滤器
8
- * import { filter as filters } from '@haluo/util'
9
- * Object.keys(filters).forEach(key => {
10
- * Vue.filter(key, filters[key])
11
- * })
12
- */
13
- 'use strict'
14
-
15
- const dateClass = require('../date')
16
- const numberClass = require('../number')
17
- const toolsClass = require('../tools')
18
-
19
- class FilterClass {
20
- /**
21
- * 格式化时间,示例:1586840260500 | format('YYYY-MM-DD HH:mm:ss')
22
- * @param {String|Number} date
23
- * @param {String} fmt 'YYYY-MM-DD HH:mm:ss'
24
- * @return {String} 'YYYY-MM-DD HH:mm:ss'
25
- */
26
- format(date: string | number, fmt: string = 'YYYY-MM-DD HH:mm:ss') {
27
- return dateClass.format(date, fmt)
28
- }
29
-
30
- /**
31
- * 格式化金额,示例:123456 | formatMoney
32
- * @param {Number} num
33
- * @return {String} 123,456
34
- */
35
- formatMoney(money: number | string): string {
36
- return numberClass.formatMoney(money)
37
- }
38
-
39
- /**
40
- * 截取数组或字符串,示例:'1234' | slice(3)
41
- * @param {Array|String} target 数组或字符串
42
- * @param {Number} length 截取长度,从0开始
43
- * @return {any}
44
- */
45
- slice(target: Array<any> | string = '', length: number = 0) {
46
- return toolsClass.slice(target, length)
47
- }
48
-
49
- install(Vue: any) {
50
- const _this = this
51
- Vue.filter('format', _this.format)
52
- Vue.filter('formatMoney', _this.formatMoney)
53
- Vue.filter('slice', _this.slice)
54
- }
55
- }
56
-
57
- module.exports = new FilterClass()
@@ -1,19 +0,0 @@
1
- interface Obj {
2
- [prop: string]: any
3
- }
4
- 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
- return Object.keys(obj).reduce((cur, key) => {
14
- (cur as Obj)[key] = obj[key] || ((obj[key] === 0 || obj[key] === false) ? obj[key] : separator)
15
- return cur
16
- }, {} as { [key in keyof T]: T[key] })
17
- }
18
- }
19
- module.exports = new Format()
@@ -1,31 +0,0 @@
1
-
2
- /**
3
- * @file: tools 常用的工具函数
4
- * @Author: wanghui
5
- */
6
- 'use strict'
7
- import { IObjectKey } from '../../types/index'
8
-
9
- class MatchClass {
10
- /**
11
- * 根据类型返回正则
12
- * @param {String} str 检测的内容
13
- * @param {String} type 检测类型
14
- * checkType('10.120.33.11', 'ip') // true
15
- * @return {Boolean} true or false
16
- */
17
- checkType(str: string, type: string): boolean {
18
- const regexp: IObjectKey<boolean> = {
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),
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),
21
- 'phone': /^1[3|4|5|6|7|8][0-9]{9}$/.test(str), // 手机号
22
- 'number': /^[0-9]+$/.test(str), // 是否全数字
23
- 'email': /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(str),
24
- 'IDCard': /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/.test(str),
25
- 'url': /[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i.test(str)
26
- };
27
- return regexp[type];
28
- }
29
- }
30
-
31
- module.exports = new MatchClass()
@@ -1,108 +0,0 @@
1
- /**
2
- * @file number 格式化
3
- * @Author: wanghui
4
- * @createBy: @2020.05.26
5
- */
6
- 'use strict'
7
-
8
- class NumberClass {
9
- /**
10
- * 个位数前面补0
11
- * @param {Number} num 需要格式化的数字
12
- * @return {String} '01'
13
- */
14
- formatNumber(num: number) {
15
- const res = num.toString();
16
- return res[1] ? res : '0' + res;
17
- }
18
-
19
- /**
20
- * 将手机号中间部分替换为星号
21
- * @param {String} phone 手机号码
22
- * @return {String} 131****1111
23
- */
24
- formatPhone(phone: string): string {
25
- return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
26
- }
27
-
28
- /**
29
- * 格式化数字 万
30
- * @param {Number} num
31
- * @return {String} 12.3万
32
- */
33
- convertToWan(num: number): string | number {
34
- let result: string | number = ''
35
- if (num < 10000) {
36
- result = num;
37
- }
38
-
39
- if (num >= 10000) {
40
- result = (num / 10000).toFixed(1) + '万';
41
- }
42
- return result;
43
- }
44
-
45
- /**
46
- * 格式化数字 k
47
- * @param {Number} num
48
- * @return {String} 1.2k
49
- */
50
- convertToThousand(num: number): string | number {
51
- let result: string | number = ''
52
- if (num < 1000) {
53
- result = num;
54
- }
55
-
56
- if (num >= 1000) {
57
- result = (num / 1000).toFixed(1) + 'k';
58
- }
59
- return result;
60
- }
61
-
62
- /**
63
- * 随机数,指定范围
64
- * @param {Number} min 开始
65
- * @param {Number} max 结束
66
- * @return {Number|Object}
67
- */
68
- random(min: number, max: number) {
69
- if (arguments.length === 2) {
70
- return Math.floor(min + Math.random() * ((max + 1) - min))
71
- } else {
72
- return null;
73
- }
74
- }
75
-
76
- /**
77
- * 格式化金额
78
- * @param {Number} num
79
- * @return {String} 123,456
80
- */
81
- formatMoney(money: number | string, signal: string): string {
82
- let result = '';
83
- if (money === '') {
84
- return result;
85
- }
86
- money = String(money).replace('.00', '');
87
- money = money.substring(money.length - 2) === '.0' ? money.replace('.0', '') : money;
88
- // 小于3位数,直接返回
89
- if (Number(money) < 1000) {
90
- return result = money;
91
- }
92
- if (money.split('.')[0].length < 3) {
93
- return result = money;
94
- }
95
- signal = signal === '' ? '' : ','
96
- let price = money.split('.')[0] + '';
97
- const pricePoint = money.split('.')[1];
98
- result = price.length > 6 ?
99
- `${price.substring(0, price.length - 6)}${signal}${price.substring(price.length - 6, price.length - 3)},${price.substring(price.length - 3, price.length)}`
100
- :
101
- `${price.substring(0, price.length - 3)}${signal}${price.substring(price.length - 3, price.length)}`
102
- result = pricePoint ? `${result}${signal}${pricePoint}` : result
103
- return result;
104
- }
105
- }
106
-
107
- module.exports = new NumberClass()
108
-
@@ -1,82 +0,0 @@
1
- /**
2
- * 异常上报日志监控类
3
- * @Author: wanghui
4
- * 常用配置 option:https://docs.sentry.io/clients/javascript/config/
5
- * 1.自动捕获vue组件内异常
6
- * 2.自动捕获promise内的异常
7
- * 3.自动捕获没有被catch的运行异常
8
- */
9
- 'use strict'
10
-
11
- import Raven from 'raven-js';
12
- // import RavenVue from 'raven-js/plugins/vue';
13
-
14
- class Report {
15
- static instance: any;
16
- constructor(Vue: Object, options = {}) {
17
- if (process.env.NODE_ENV !== 'development') {
18
- // todo
19
- }
20
- this.vue = Vue;
21
- this.options = options;
22
- }
23
-
24
- [key: string]: any;
25
-
26
- static getInstance(Vue: Object, Option: Object) {
27
- if (!(this.instance instanceof this)) {
28
- this.instance = new this(Vue, Option);
29
- this.instance.install();
30
- }
31
- return this.instance;
32
- }
33
-
34
- install() {
35
- if (process.env.NODE_ENV !== 'development') {
36
- // Raven.config(this.options.dsn, {
37
- // environment: process.env.NODE_ENV,
38
- // }).addPlugin(RavenVue, this.Vue).install();
39
- // raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
40
-
41
- // 记录用户信息
42
- Raven.setUserContext({ user: this.options.user || '' });
43
-
44
- // 设置全局tag标签
45
- Raven.setTagsContext({ environment: this.options.env || '' });
46
- }
47
- }
48
-
49
- /**
50
- * 主动上报
51
- * @param {String} data
52
- * @param {String} type 'info','warning','error'
53
- * @param {Object} options
54
- */
55
- log(data: any = null, type: any = 'error', options: any = {}) {
56
- // 添加面包屑
57
- Raven.captureBreadcrumb({
58
- message: data,
59
- category: 'manual message',
60
- });
61
- // 异常上报
62
- if (data instanceof Error) {
63
- Raven.captureException(data, {
64
- level: type,
65
- logger: 'manual exception',
66
- tags: { options },
67
- });
68
- } else {
69
- Raven.captureException('error', {
70
- level: type,
71
- logger: 'manual data',
72
- extra: {
73
- data,
74
- options: this.options,
75
- date: new Date(),
76
- },
77
- });
78
- }
79
- }
80
- }
81
-
82
- export default Report;