@haluo/util 2.0.33-beta.9 → 2.0.34
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.js +20 -19
- package/dist/modules/app-call/configs.js +15 -10
- package/dist/modules/app-call/core.d.ts +2 -2
- package/dist/modules/app-call/core.js +60 -51
- package/dist/modules/app-call/extensions.d.ts +4 -3
- package/dist/modules/app-call/extensions.js +357 -290
- package/dist/modules/app-call/index.js +9 -9
- package/dist/modules/app-call/offline.js +43 -35
- package/dist/modules/app-call/types.d.ts +18 -4
- package/dist/modules/cookie/index.js +22 -17
- package/dist/modules/date/index.js +54 -48
- package/dist/modules/dom/index.js +21 -15
- package/dist/modules/filter/index.js +14 -8
- package/dist/modules/format/index.js +9 -5
- package/dist/modules/match/index.js +8 -5
- package/dist/modules/monitor/lib/jsError.js +27 -38
- package/dist/modules/monitor/lib/timing.js +15 -17
- package/dist/modules/monitor/lib/xhr.js +26 -25
- package/dist/modules/monitor/utils/tracker.js +22 -10
- package/dist/modules/number/index.js +33 -30
- package/dist/modules/open-app/index.d.ts +2 -1
- package/dist/modules/open-app/index.js +52 -62
- package/dist/modules/sentry/index.js +16 -12
- package/dist/modules/tools/index.d.ts +3 -3
- package/dist/modules/tools/index.js +164 -154
- package/dist/modules/track/index.js +149 -96
- package/dist/modules/track/types.d.ts +1 -1
- package/dist/modules/upload/aliOss.d.ts +36 -4
- package/dist/modules/upload/aliOss.js +569 -396
- package/dist/modules/upload/index.js +32 -29
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/modules/app-call/partner-bridge.d.ts +0 -5
- package/dist/modules/app-call/partner-bridge.js +0 -68
|
@@ -7,28 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import qs from 'qs';
|
|
9
9
|
import tools from '../tools';
|
|
10
|
-
|
|
11
|
-
env;
|
|
12
|
-
postJddTrack;
|
|
13
|
-
trackId;
|
|
14
|
-
openAppState;
|
|
15
|
-
ua;
|
|
16
|
-
_wx;
|
|
17
|
-
_android;
|
|
18
|
-
_isHarmonyos;
|
|
19
|
-
_ios;
|
|
20
|
-
_isPrice;
|
|
21
|
-
currentEnv;
|
|
22
|
-
appUrl;
|
|
23
|
-
appStoreUrl;
|
|
24
|
-
underway;
|
|
10
|
+
var OpenAppClass = /** @class */ (function () {
|
|
25
11
|
/**
|
|
26
12
|
* @param {Object} env - 环境配置,必须
|
|
27
13
|
* @param {Function} postJddTrack - 埋点方法,必须
|
|
28
14
|
* @param {String} trackId - 埋点id,可选
|
|
29
15
|
* @param {Object} openAppState - 打开app状态,可选
|
|
30
16
|
*/
|
|
31
|
-
|
|
17
|
+
function OpenAppClass(env, postJddTrack, trackId, openAppState) {
|
|
18
|
+
if (trackId === void 0) { trackId = 'S_00000000000108'; }
|
|
32
19
|
this.env = env; // 环境配置,必须
|
|
33
20
|
this.postJddTrack = postJddTrack; // 埋点方法,必须
|
|
34
21
|
this.trackId = trackId; // 埋点id,可选
|
|
@@ -48,8 +35,8 @@ class OpenAppClass {
|
|
|
48
35
|
/**
|
|
49
36
|
* 根据域名动态获取配置,保证多项目代码一样
|
|
50
37
|
*/
|
|
51
|
-
getCurrentEnv() {
|
|
52
|
-
|
|
38
|
+
OpenAppClass.prototype.getCurrentEnv = function () {
|
|
39
|
+
var host = location.host;
|
|
53
40
|
if (host.includes('58moto')) {
|
|
54
41
|
this.currentEnv = {
|
|
55
42
|
motoAndroidScheme: this.env.motoAndroidScheme,
|
|
@@ -90,11 +77,11 @@ class OpenAppClass {
|
|
|
90
77
|
APPLINKIOS: this.env.dronefineAPPLINKIOS,
|
|
91
78
|
};
|
|
92
79
|
}
|
|
93
|
-
}
|
|
80
|
+
};
|
|
94
81
|
/**
|
|
95
82
|
* 打开APP主流程
|
|
96
83
|
*/
|
|
97
|
-
invoke() {
|
|
84
|
+
OpenAppClass.prototype.invoke = function () {
|
|
98
85
|
if (this.underway) {
|
|
99
86
|
return;
|
|
100
87
|
}
|
|
@@ -105,13 +92,13 @@ class OpenAppClass {
|
|
|
105
92
|
}
|
|
106
93
|
this.underway = true;
|
|
107
94
|
// 生成url并且放到剪贴板
|
|
108
|
-
|
|
95
|
+
var url = this.getSechmaUrl();
|
|
109
96
|
if (url) {
|
|
110
97
|
tools.clipboard(url);
|
|
111
98
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.postJddTrack(this.trackId, { tag });
|
|
99
|
+
var apk = JSON.parse(sessionStorage.getItem('downloadApk') || '{}');
|
|
100
|
+
var tag = this._ios ? (apk.channelName ? "App Store-".concat(apk.channelName) : 'App Store') : (apk.channelName ? "\u6E20\u9053".concat(apk.channelName, "\u5305") : '安卓包');
|
|
101
|
+
this.postJddTrack(this.trackId, { tag: tag });
|
|
115
102
|
// 厂家版 app
|
|
116
103
|
if (this._android && location.href.includes('downloadPrise')) {
|
|
117
104
|
window.location.href = (apk && apk.path) || this.appUrl;
|
|
@@ -121,7 +108,7 @@ class OpenAppClass {
|
|
|
121
108
|
// 客户端打开app-下载页特殊处理
|
|
122
109
|
if (location.href.includes('download') && window.AppCall && window.AppCall.has('openOtherAppUrlRouter')) {
|
|
123
110
|
this.underway = false;
|
|
124
|
-
return window.AppCall.openOtherAppUrlRouter({ appUrlRouter:
|
|
111
|
+
return window.AppCall.openOtherAppUrlRouter({ appUrlRouter: "https://".concat(location.host, "/home") });
|
|
125
112
|
}
|
|
126
113
|
// 客户端打开app
|
|
127
114
|
if (window.AppCall && window.AppCall.has('openOtherAppUrlRouter')) {
|
|
@@ -134,21 +121,22 @@ class OpenAppClass {
|
|
|
134
121
|
url = this.appStoreUrl;
|
|
135
122
|
}
|
|
136
123
|
this.open(url);
|
|
137
|
-
}
|
|
124
|
+
};
|
|
138
125
|
// 获取自定义的url
|
|
139
|
-
getUrl() {
|
|
140
|
-
|
|
141
|
-
|
|
126
|
+
OpenAppClass.prototype.getUrl = function () {
|
|
127
|
+
var searchParams = qs.parse(location.search.slice(1)); // 路由的query
|
|
128
|
+
var url = searchParams.customOpenUrl || window.location.href;
|
|
142
129
|
return url;
|
|
143
|
-
}
|
|
130
|
+
};
|
|
144
131
|
/**
|
|
145
132
|
* 获取打开 app sechma url
|
|
146
133
|
* @returns {string | undefined} 打开app的schema或跳转链接
|
|
147
134
|
* params:params={"type":"","id":0,"name":"","travelId":0}
|
|
148
135
|
* type:原生页面key(必须);id:页面id(可选);subject 短话题、版块名称 或 页面标题(可选);travelId 游记id(可选)
|
|
149
136
|
*/
|
|
150
|
-
getSechmaUrl() {
|
|
151
|
-
|
|
137
|
+
OpenAppClass.prototype.getSechmaUrl = function () {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
var keys = {
|
|
152
140
|
'/posts/': 'thread_detail',
|
|
153
141
|
'/detailedForum/': 'forum_detail',
|
|
154
142
|
'/video/': 'video_detail',
|
|
@@ -167,94 +155,96 @@ class OpenAppClass {
|
|
|
167
155
|
'/coupon-detail': 'coupon_detail',
|
|
168
156
|
'/news/': 'essay_detail' // 文章详情
|
|
169
157
|
};
|
|
170
|
-
|
|
158
|
+
var target = Object.keys(keys).filter(function (value) {
|
|
171
159
|
return window.location.href.indexOf(value) > -1;
|
|
172
160
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
161
|
+
var type = target && target[0] && keys[target[0]];
|
|
162
|
+
var searchParams = qs.parse(location.search.slice(1)); // 路由的query
|
|
163
|
+
var id = parseInt(location.pathname.split('/').reverse()[0]) ||
|
|
176
164
|
parseInt(searchParams.id) ||
|
|
177
165
|
parseInt(searchParams.carId) ||
|
|
178
166
|
parseInt(searchParams.goodId); // 页面id
|
|
179
|
-
|
|
180
|
-
|
|
167
|
+
var subject = searchParams.subject || undefined; // 页面标题或name
|
|
168
|
+
var temp = {
|
|
181
169
|
relationType: type,
|
|
182
170
|
id: id,
|
|
183
171
|
name: subject
|
|
184
172
|
};
|
|
185
|
-
|
|
186
|
-
|
|
173
|
+
var data = ((_b = (_a = this.openAppState) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.openApps) || {};
|
|
174
|
+
var open_url = '';
|
|
187
175
|
if (data.type && data.href === window.location.href) {
|
|
188
176
|
temp.relationType = keys[data.type] || '';
|
|
189
177
|
temp.id = data.id || '';
|
|
190
178
|
temp.name = data.title || '';
|
|
191
179
|
open_url = data.url || '';
|
|
192
180
|
}
|
|
193
|
-
|
|
181
|
+
var openUrl = open_url || searchParams.customOpenUrl || window.location.href;
|
|
194
182
|
// activityId 大于零,type 为 activity
|
|
195
183
|
if (searchParams.activityId) {
|
|
196
184
|
temp.relationType = 'activity';
|
|
197
185
|
temp.link = decodeURIComponent(decodeURIComponent(openUrl));
|
|
198
186
|
}
|
|
199
187
|
temp.jumpUrl = decodeURIComponent(decodeURIComponent(openUrl));
|
|
200
|
-
|
|
188
|
+
var params = JSON.stringify(temp);
|
|
201
189
|
if (this._ios) {
|
|
202
|
-
return
|
|
190
|
+
return "".concat(this.currentEnv.motoIOSScheme, "?params=").concat(params);
|
|
203
191
|
}
|
|
204
192
|
if (this._android || this._isHarmonyos) {
|
|
205
|
-
|
|
193
|
+
var url = this._wx ? "".concat(this.appUrl, "&android_scheme=").concat(this.currentEnv.motoAndroidScheme, "?params=").concat(params) : "".concat(this.currentEnv.motoAndroidScheme, "?params=").concat(params);
|
|
206
194
|
return url;
|
|
207
195
|
}
|
|
208
196
|
return undefined;
|
|
209
|
-
}
|
|
197
|
+
};
|
|
210
198
|
/**
|
|
211
199
|
* 方法一(推荐):打开APP
|
|
212
200
|
* http://www.cnblogs.com/shadajin/p/5724117.html
|
|
213
201
|
*/
|
|
214
|
-
open(openUrl) {
|
|
202
|
+
OpenAppClass.prototype.open = function (openUrl) {
|
|
203
|
+
var _this = this;
|
|
215
204
|
if (!openUrl) {
|
|
216
205
|
this.underway = false;
|
|
217
206
|
return;
|
|
218
207
|
}
|
|
219
208
|
if (this._ios) {
|
|
220
209
|
this.underway = false;
|
|
221
|
-
setTimeout(()
|
|
210
|
+
setTimeout(function () { return (location.href = _this.appStoreUrl || ''); }, 3000);
|
|
222
211
|
return (location.href = openUrl);
|
|
223
212
|
}
|
|
224
213
|
if (this._android) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
document.body.appendChild(
|
|
214
|
+
var ifr_1 = document.createElement('iframe');
|
|
215
|
+
ifr_1.src = openUrl;
|
|
216
|
+
ifr_1.style.display = 'none';
|
|
217
|
+
document.body.appendChild(ifr_1);
|
|
229
218
|
setTimeout(function () {
|
|
230
|
-
document.body.removeChild(
|
|
219
|
+
document.body.removeChild(ifr_1);
|
|
231
220
|
}, 3000);
|
|
232
221
|
}
|
|
233
|
-
return new Promise((resolve, reject)
|
|
222
|
+
return new Promise(function (resolve, reject) {
|
|
234
223
|
// 检查APP是否打开
|
|
235
|
-
|
|
224
|
+
var check = function (elsTime) {
|
|
236
225
|
if (elsTime > 3000 || document.hidden) {
|
|
237
226
|
// @ts-ignore
|
|
238
227
|
resolve('成功打开APP');
|
|
239
228
|
}
|
|
240
229
|
else {
|
|
241
230
|
// @ts-ignore
|
|
242
|
-
window.location.href =
|
|
231
|
+
window.location.href = "https://".concat(location.host, "/download");
|
|
243
232
|
reject('打开APP失败');
|
|
244
233
|
}
|
|
245
|
-
|
|
234
|
+
_this.underway = false;
|
|
246
235
|
};
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
236
|
+
var _count = 0;
|
|
237
|
+
var _clickTime = +new Date();
|
|
238
|
+
var intHandle = setInterval(function () {
|
|
250
239
|
_count++;
|
|
251
|
-
|
|
240
|
+
var elsTime = +new Date() - _clickTime;
|
|
252
241
|
if (_count >= 100 || elsTime > 3000) {
|
|
253
242
|
clearInterval(intHandle);
|
|
254
243
|
check(elsTime);
|
|
255
244
|
}
|
|
256
245
|
}, 20);
|
|
257
246
|
});
|
|
258
|
-
}
|
|
259
|
-
|
|
247
|
+
};
|
|
248
|
+
return OpenAppClass;
|
|
249
|
+
}());
|
|
260
250
|
export default OpenAppClass;
|
|
@@ -9,23 +9,23 @@
|
|
|
9
9
|
'use strict';
|
|
10
10
|
import Raven from 'raven-js';
|
|
11
11
|
// import RavenVue from 'raven-js/plugins/vue';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var Report = /** @class */ (function () {
|
|
13
|
+
function Report(Vue, options) {
|
|
14
|
+
if (options === void 0) { options = {}; }
|
|
15
15
|
if (process.env.NODE_ENV !== 'development') {
|
|
16
16
|
// todo
|
|
17
17
|
}
|
|
18
18
|
this.vue = Vue;
|
|
19
19
|
this.options = options;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
Report.getInstance = function (Vue, Option) {
|
|
22
22
|
if (!(this.instance instanceof this)) {
|
|
23
23
|
this.instance = new this(Vue, Option);
|
|
24
24
|
this.instance.install();
|
|
25
25
|
}
|
|
26
26
|
return this.instance;
|
|
27
|
-
}
|
|
28
|
-
install() {
|
|
27
|
+
};
|
|
28
|
+
Report.prototype.install = function () {
|
|
29
29
|
if (process.env.NODE_ENV !== 'development') {
|
|
30
30
|
// Raven.config(this.options.dsn, {
|
|
31
31
|
// environment: process.env.NODE_ENV,
|
|
@@ -36,14 +36,17 @@ class Report {
|
|
|
36
36
|
// 设置全局tag标签
|
|
37
37
|
Raven.setTagsContext({ environment: this.options.env || '' });
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
};
|
|
40
40
|
/**
|
|
41
41
|
* 主动上报
|
|
42
42
|
* @param {String} data
|
|
43
43
|
* @param {String} type 'info','warning','error'
|
|
44
44
|
* @param {Object} options
|
|
45
45
|
*/
|
|
46
|
-
log
|
|
46
|
+
Report.prototype.log = function (data, type, options) {
|
|
47
|
+
if (data === void 0) { data = null; }
|
|
48
|
+
if (type === void 0) { type = 'error'; }
|
|
49
|
+
if (options === void 0) { options = {}; }
|
|
47
50
|
// 添加面包屑
|
|
48
51
|
Raven.captureBreadcrumb({
|
|
49
52
|
message: data,
|
|
@@ -54,7 +57,7 @@ class Report {
|
|
|
54
57
|
Raven.captureException(data, {
|
|
55
58
|
level: type,
|
|
56
59
|
logger: 'manual exception',
|
|
57
|
-
tags: { options },
|
|
60
|
+
tags: { options: options },
|
|
58
61
|
});
|
|
59
62
|
}
|
|
60
63
|
else {
|
|
@@ -62,12 +65,13 @@ class Report {
|
|
|
62
65
|
level: type,
|
|
63
66
|
logger: 'manual data',
|
|
64
67
|
extra: {
|
|
65
|
-
data,
|
|
68
|
+
data: data,
|
|
66
69
|
options: this.options,
|
|
67
70
|
date: new Date(),
|
|
68
71
|
},
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
74
|
+
};
|
|
75
|
+
return Report;
|
|
76
|
+
}());
|
|
73
77
|
export default Report;
|
|
@@ -51,13 +51,13 @@ declare class ToolsClass {
|
|
|
51
51
|
* @param {String} url
|
|
52
52
|
* @return {Promise}
|
|
53
53
|
*/
|
|
54
|
-
loadJs(url: string): Promise<unknown
|
|
54
|
+
loadJs(url: string): Error | Promise<unknown>;
|
|
55
55
|
/**
|
|
56
56
|
* 动态加载样式
|
|
57
57
|
* @param {String} url
|
|
58
58
|
* @return {Promise}
|
|
59
59
|
*/
|
|
60
|
-
loadCss(url: string): Promise<unknown
|
|
60
|
+
loadCss(url: string): Error | Promise<unknown>;
|
|
61
61
|
/**
|
|
62
62
|
* 蒙层显示后,html禁止滚动操作
|
|
63
63
|
* @param {String} className
|
|
@@ -76,7 +76,7 @@ declare class ToolsClass {
|
|
|
76
76
|
* @param {String} str
|
|
77
77
|
* @return {String}
|
|
78
78
|
*/
|
|
79
|
-
clipboard(str: string): Promise<void
|
|
79
|
+
clipboard(str: string): Error | Promise<void>;
|
|
80
80
|
/**
|
|
81
81
|
* 首字母大写
|
|
82
82
|
* @param {String} str
|