@taole/dev-helper 0.1.25 → 0.1.26
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/open-diandian.umd.js +35 -26
- package/open-diandian/index.js +35 -26
- package/package.json +1 -1
|
@@ -227,9 +227,7 @@
|
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
229
|
this._log('open-diandian: final fallback go', this._alink_fin_5s);
|
|
230
|
-
|
|
231
|
-
lnkFinal.href = this._alink_fin_5s;
|
|
232
|
-
lnkFinal.click();
|
|
230
|
+
this._openFallbackLink(this._alink_fin_5s);
|
|
233
231
|
}, 5000);
|
|
234
232
|
}
|
|
235
233
|
});
|
|
@@ -261,11 +259,7 @@
|
|
|
261
259
|
if (document.hidden) {
|
|
262
260
|
if (this._clickLink) {
|
|
263
261
|
this._log("open app successfully");
|
|
264
|
-
|
|
265
|
-
clearTimeout(this._alink_click_timer);
|
|
266
|
-
this._alink_click_timer = null;
|
|
267
|
-
}
|
|
268
|
-
this._clickLink = false;
|
|
262
|
+
this._cancelLaunchFallback();
|
|
269
263
|
}
|
|
270
264
|
}
|
|
271
265
|
});
|
|
@@ -281,32 +275,44 @@
|
|
|
281
275
|
}
|
|
282
276
|
}
|
|
283
277
|
_handleAlinkClick(event) {
|
|
278
|
+
this._writeClickboard();
|
|
279
|
+
this._cancelLaunchFallback();
|
|
280
|
+
if (this._alink_link === this._alink_fallback) {
|
|
281
|
+
// 没有可用的拉端链接,点击本身就是兜底。
|
|
282
|
+
if (this._useOpenInstall()) {
|
|
283
|
+
event.preventDefault();
|
|
284
|
+
this._wakeupOpenInstall();
|
|
285
|
+
}
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
// 先使用原链接拉端,页面没有隐藏才执行兜底。
|
|
289
|
+
this._clickLink = true;
|
|
290
|
+
this._alink_click_timer = setTimeout(() => {
|
|
291
|
+
this._cancelLaunchFallback();
|
|
292
|
+
if (!this._isConnected || document.hidden) return;
|
|
293
|
+
this._log('open app timed out, run fallback');
|
|
294
|
+
this._openFallbackLink(this._alink_fallback);
|
|
295
|
+
}, this._fallbackTime);
|
|
296
|
+
}
|
|
297
|
+
_cancelLaunchFallback() {
|
|
298
|
+
clearTimeout(this._alink_click_timer);
|
|
299
|
+
this._alink_click_timer = null;
|
|
300
|
+
this._clickLink = false;
|
|
301
|
+
}
|
|
302
|
+
_openFallbackLink(href) {
|
|
284
303
|
if (this._useOpenInstall()) {
|
|
285
|
-
event.preventDefault();
|
|
286
304
|
this._wakeupOpenInstall();
|
|
287
305
|
return;
|
|
288
306
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
// 端外使用scheme打开app,3秒内如果页面有隐藏过,那么认为拉端成功了,否则跳转到fallback链接
|
|
293
|
-
if (this._alink_click_timer) {
|
|
294
|
-
clearTimeout(this._alink_click_timer);
|
|
295
|
-
}
|
|
296
|
-
this._clickLink = true;
|
|
297
|
-
this._alink_click_timer = setTimeout(() => {
|
|
298
|
-
this._log("3s timeout, open app failed, jump to fallback link");
|
|
299
|
-
this._alink_click_timer = null;
|
|
300
|
-
var tmplnk = document.createElement("a");
|
|
301
|
-
tmplnk.href = this._alink_fallback;
|
|
302
|
-
tmplnk.click();
|
|
303
|
-
}, this._fallbackTime);
|
|
304
|
-
}
|
|
307
|
+
const link = document.createElement('a');
|
|
308
|
+
link.href = href;
|
|
309
|
+
link.click();
|
|
305
310
|
}
|
|
306
311
|
disconnectedCallback() {
|
|
307
312
|
this._log("disconnectedCallback");
|
|
308
313
|
this._isConnected = false;
|
|
309
314
|
this._openInstallPending = false;
|
|
315
|
+
this._cancelLaunchFallback();
|
|
310
316
|
if (this._openAppTag) {
|
|
311
317
|
this._openAppTag.remove();
|
|
312
318
|
this._openAppTag = null;
|
|
@@ -520,7 +526,10 @@
|
|
|
520
526
|
this._openAppTag.setAttribute('appid', this._appid);
|
|
521
527
|
this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
|
|
522
528
|
} else if (this._alink) {
|
|
523
|
-
|
|
529
|
+
// 开启 OpenInstall 时,由组件统一触发兜底,避免 Android Intent 直接跳转。
|
|
530
|
+
this._alink.href = this._useOpenInstall() && this._alink_link.startsWith('intent:')
|
|
531
|
+
? this._alink_link.replace(/;S\.browser_fallback_url=[^;]*/, '')
|
|
532
|
+
: this._alink_link;
|
|
524
533
|
}
|
|
525
534
|
}
|
|
526
535
|
};
|
package/open-diandian/index.js
CHANGED
|
@@ -222,9 +222,7 @@ function createOpenDiandianElementClass() {
|
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
224
|
this._log('open-diandian: final fallback go', this._alink_fin_5s);
|
|
225
|
-
|
|
226
|
-
lnkFinal.href = this._alink_fin_5s;
|
|
227
|
-
lnkFinal.click();
|
|
225
|
+
this._openFallbackLink(this._alink_fin_5s);
|
|
228
226
|
}, 5000);
|
|
229
227
|
}
|
|
230
228
|
});
|
|
@@ -256,11 +254,7 @@ function createOpenDiandianElementClass() {
|
|
|
256
254
|
if (document.hidden) {
|
|
257
255
|
if (this._clickLink) {
|
|
258
256
|
this._log("open app successfully");
|
|
259
|
-
|
|
260
|
-
clearTimeout(this._alink_click_timer);
|
|
261
|
-
this._alink_click_timer = null;
|
|
262
|
-
}
|
|
263
|
-
this._clickLink = false;
|
|
257
|
+
this._cancelLaunchFallback();
|
|
264
258
|
}
|
|
265
259
|
}
|
|
266
260
|
});
|
|
@@ -276,32 +270,44 @@ function createOpenDiandianElementClass() {
|
|
|
276
270
|
}
|
|
277
271
|
}
|
|
278
272
|
_handleAlinkClick(event) {
|
|
273
|
+
this._writeClickboard();
|
|
274
|
+
this._cancelLaunchFallback();
|
|
275
|
+
if (this._alink_link === this._alink_fallback) {
|
|
276
|
+
// 没有可用的拉端链接,点击本身就是兜底。
|
|
277
|
+
if (this._useOpenInstall()) {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
this._wakeupOpenInstall();
|
|
280
|
+
}
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
// 先使用原链接拉端,页面没有隐藏才执行兜底。
|
|
284
|
+
this._clickLink = true;
|
|
285
|
+
this._alink_click_timer = setTimeout(() => {
|
|
286
|
+
this._cancelLaunchFallback();
|
|
287
|
+
if (!this._isConnected || document.hidden) return;
|
|
288
|
+
this._log('open app timed out, run fallback');
|
|
289
|
+
this._openFallbackLink(this._alink_fallback);
|
|
290
|
+
}, this._fallbackTime);
|
|
291
|
+
}
|
|
292
|
+
_cancelLaunchFallback() {
|
|
293
|
+
clearTimeout(this._alink_click_timer);
|
|
294
|
+
this._alink_click_timer = null;
|
|
295
|
+
this._clickLink = false;
|
|
296
|
+
}
|
|
297
|
+
_openFallbackLink(href) {
|
|
279
298
|
if (this._useOpenInstall()) {
|
|
280
|
-
event.preventDefault();
|
|
281
299
|
this._wakeupOpenInstall();
|
|
282
300
|
return;
|
|
283
301
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
// 端外使用scheme打开app,3秒内如果页面有隐藏过,那么认为拉端成功了,否则跳转到fallback链接
|
|
288
|
-
if (this._alink_click_timer) {
|
|
289
|
-
clearTimeout(this._alink_click_timer);
|
|
290
|
-
}
|
|
291
|
-
this._clickLink = true;
|
|
292
|
-
this._alink_click_timer = setTimeout(() => {
|
|
293
|
-
this._log("3s timeout, open app failed, jump to fallback link");
|
|
294
|
-
this._alink_click_timer = null;
|
|
295
|
-
var tmplnk = document.createElement("a");
|
|
296
|
-
tmplnk.href = this._alink_fallback;
|
|
297
|
-
tmplnk.click();
|
|
298
|
-
}, this._fallbackTime);
|
|
299
|
-
}
|
|
302
|
+
const link = document.createElement('a');
|
|
303
|
+
link.href = href;
|
|
304
|
+
link.click();
|
|
300
305
|
}
|
|
301
306
|
disconnectedCallback() {
|
|
302
307
|
this._log("disconnectedCallback")
|
|
303
308
|
this._isConnected = false;
|
|
304
309
|
this._openInstallPending = false;
|
|
310
|
+
this._cancelLaunchFallback();
|
|
305
311
|
if (this._openAppTag) {
|
|
306
312
|
this._openAppTag.remove();
|
|
307
313
|
this._openAppTag = null;
|
|
@@ -515,7 +521,10 @@ function createOpenDiandianElementClass() {
|
|
|
515
521
|
this._openAppTag.setAttribute('appid', this._appid);
|
|
516
522
|
this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
|
|
517
523
|
} else if (this._alink) {
|
|
518
|
-
|
|
524
|
+
// 开启 OpenInstall 时,由组件统一触发兜底,避免 Android Intent 直接跳转。
|
|
525
|
+
this._alink.href = this._useOpenInstall() && this._alink_link.startsWith('intent:')
|
|
526
|
+
? this._alink_link.replace(/;S\.browser_fallback_url=[^;]*/, '')
|
|
527
|
+
: this._alink_link;
|
|
519
528
|
}
|
|
520
529
|
}
|
|
521
530
|
};
|