@taole/dev-helper 0.1.25 → 0.1.27-beta
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 +34 -24
- package/open-diandian/index.js +34 -24
- 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,45 @@
|
|
|
281
275
|
}
|
|
282
276
|
}
|
|
283
277
|
_handleAlinkClick(event) {
|
|
278
|
+
this._writeClickboard();
|
|
279
|
+
this._cancelLaunchFallback();
|
|
284
280
|
if (this._useOpenInstall()) {
|
|
285
281
|
event.preventDefault();
|
|
282
|
+
if (this._alink_link !== this._alink_fallback) {
|
|
283
|
+
// 默认的 a 标签跳转发生在事件处理完成之后,先主动执行拉端。
|
|
284
|
+
this._openFallbackLink(this._alink.href);
|
|
285
|
+
}
|
|
286
|
+
// 在同一次点击中调用,尽可能保留 SDK 写剪贴板所需的用户激活状态。
|
|
286
287
|
this._wakeupOpenInstall();
|
|
287
288
|
return;
|
|
288
289
|
}
|
|
289
|
-
this.
|
|
290
|
-
|
|
291
|
-
this._log("this._alink is clicked");
|
|
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);
|
|
290
|
+
if (this._alink_link === this._alink_fallback) {
|
|
291
|
+
return;
|
|
304
292
|
}
|
|
293
|
+
// 先使用原链接拉端,页面没有隐藏才执行兜底。
|
|
294
|
+
this._clickLink = true;
|
|
295
|
+
this._alink_click_timer = setTimeout(() => {
|
|
296
|
+
this._cancelLaunchFallback();
|
|
297
|
+
if (!this._isConnected || document.hidden) return;
|
|
298
|
+
this._log('open app timed out, run fallback');
|
|
299
|
+
this._openFallbackLink(this._alink_fallback);
|
|
300
|
+
}, this._fallbackTime);
|
|
301
|
+
}
|
|
302
|
+
_cancelLaunchFallback() {
|
|
303
|
+
clearTimeout(this._alink_click_timer);
|
|
304
|
+
this._alink_click_timer = null;
|
|
305
|
+
this._clickLink = false;
|
|
306
|
+
}
|
|
307
|
+
_openFallbackLink(href) {
|
|
308
|
+
const link = document.createElement('a');
|
|
309
|
+
link.href = href;
|
|
310
|
+
link.click();
|
|
305
311
|
}
|
|
306
312
|
disconnectedCallback() {
|
|
307
313
|
this._log("disconnectedCallback");
|
|
308
314
|
this._isConnected = false;
|
|
309
315
|
this._openInstallPending = false;
|
|
316
|
+
this._cancelLaunchFallback();
|
|
310
317
|
if (this._openAppTag) {
|
|
311
318
|
this._openAppTag.remove();
|
|
312
319
|
this._openAppTag = null;
|
|
@@ -520,7 +527,10 @@
|
|
|
520
527
|
this._openAppTag.setAttribute('appid', this._appid);
|
|
521
528
|
this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
|
|
522
529
|
} else if (this._alink) {
|
|
523
|
-
|
|
530
|
+
// 开启 OpenInstall 时,由组件统一触发兜底,避免 Android Intent 直接跳转。
|
|
531
|
+
this._alink.href = this._useOpenInstall() && this._alink_link.startsWith('intent:')
|
|
532
|
+
? this._alink_link.replace(/;S\.browser_fallback_url=[^;]*/, '')
|
|
533
|
+
: this._alink_link;
|
|
524
534
|
}
|
|
525
535
|
}
|
|
526
536
|
};
|
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,45 @@ function createOpenDiandianElementClass() {
|
|
|
276
270
|
}
|
|
277
271
|
}
|
|
278
272
|
_handleAlinkClick(event) {
|
|
273
|
+
this._writeClickboard();
|
|
274
|
+
this._cancelLaunchFallback();
|
|
279
275
|
if (this._useOpenInstall()) {
|
|
280
276
|
event.preventDefault();
|
|
277
|
+
if (this._alink_link !== this._alink_fallback) {
|
|
278
|
+
// 默认的 a 标签跳转发生在事件处理完成之后,先主动执行拉端。
|
|
279
|
+
this._openFallbackLink(this._alink.href);
|
|
280
|
+
}
|
|
281
|
+
// 在同一次点击中调用,尽可能保留 SDK 写剪贴板所需的用户激活状态。
|
|
281
282
|
this._wakeupOpenInstall();
|
|
282
283
|
return;
|
|
283
284
|
}
|
|
284
|
-
this.
|
|
285
|
-
|
|
286
|
-
this._log("this._alink is clicked");
|
|
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);
|
|
285
|
+
if (this._alink_link === this._alink_fallback) {
|
|
286
|
+
return;
|
|
299
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) {
|
|
303
|
+
const link = document.createElement('a');
|
|
304
|
+
link.href = href;
|
|
305
|
+
link.click();
|
|
300
306
|
}
|
|
301
307
|
disconnectedCallback() {
|
|
302
308
|
this._log("disconnectedCallback")
|
|
303
309
|
this._isConnected = false;
|
|
304
310
|
this._openInstallPending = false;
|
|
311
|
+
this._cancelLaunchFallback();
|
|
305
312
|
if (this._openAppTag) {
|
|
306
313
|
this._openAppTag.remove();
|
|
307
314
|
this._openAppTag = null;
|
|
@@ -515,7 +522,10 @@ function createOpenDiandianElementClass() {
|
|
|
515
522
|
this._openAppTag.setAttribute('appid', this._appid);
|
|
516
523
|
this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
|
|
517
524
|
} else if (this._alink) {
|
|
518
|
-
|
|
525
|
+
// 开启 OpenInstall 时,由组件统一触发兜底,避免 Android Intent 直接跳转。
|
|
526
|
+
this._alink.href = this._useOpenInstall() && this._alink_link.startsWith('intent:')
|
|
527
|
+
? this._alink_link.replace(/;S\.browser_fallback_url=[^;]*/, '')
|
|
528
|
+
: this._alink_link;
|
|
519
529
|
}
|
|
520
530
|
}
|
|
521
531
|
};
|