@taole/dev-helper 0.0.23 → 0.0.25

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.
@@ -55,6 +55,13 @@
55
55
  this.attachShadow({ mode: 'open' });
56
56
  this.shadowRoot.appendChild(this._template.content);
57
57
  console.log('open-diandian: wx-open-launch-app appended');
58
+ // 监听打开app失败的情况,跳转fallback链接
59
+ this._openAppTag.addEventListener('error', (e)=>{
60
+ var tmplnk = document.createElement("a");
61
+ tmplnk.href = this._alink_fallback;
62
+ tmplnk.click();
63
+ console.log('open-diandian: wx-open-launch-app error',this._alink_fallback);
64
+ });
58
65
  } else {
59
66
  this._updateTagAttr();
60
67
  }
@@ -120,7 +127,16 @@
120
127
  this._template.innerHTML = '<style>:host {display: block;width: 100%;height: 100%;overflow: hidden;opacity: 0;background:transparent;}</style>';
121
128
  }
122
129
  }
130
+ _genFallbackLink() {
131
+ if (this._isIOS) {
132
+ this._alink_fallback = "https://apps.apple.com/cn/app/%E7%82%B9%E7%82%B9-%E8%AF%AD%E9%9F%B3%E5%BC%80%E9%BB%91/id1449564746";
133
+ } else {
134
+ var packageName = "com.tuwan.yw";
135
+ this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
136
+ }
137
+ }
123
138
  _updateTagAttr() {
139
+ this._genFallbackLink();
124
140
  if (this._openAppTag) {
125
141
  this._openAppTag.setAttribute('appid', this.getAttribute('appid') || this._defaultAppid);
126
142
  this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
@@ -128,10 +144,8 @@
128
144
  // TODO: 如果设置了点点以外的appid,这里其实是有问题的,待后续更新优化
129
145
  if (this._isIOS) {
130
146
  this._alink.href = "com.tuwan.diandian://openPage";
131
- this._alink_fallback = "https://apps.apple.com/cn/app/%E7%82%B9%E7%82%B9-%E8%AF%AD%E9%9F%B3%E5%BC%80%E9%BB%91/id1449564746";
132
147
  } else {
133
148
  var packageName = "com.tuwan.yw";
134
- this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
135
149
  this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
136
150
  }
137
151
  }
@@ -49,6 +49,13 @@ function defineTag() {
49
49
  this.attachShadow({ mode: 'open' });
50
50
  this.shadowRoot.appendChild(this._template.content);
51
51
  console.log('open-diandian: wx-open-launch-app appended');
52
+ // 监听打开app失败的情况,跳转fallback链接
53
+ this._openAppTag.addEventListener('error', (e)=>{
54
+ var tmplnk = document.createElement("a");
55
+ tmplnk.href = this._alink_fallback;
56
+ tmplnk.click();
57
+ console.log('open-diandian: wx-open-launch-app error',this._alink_fallback);
58
+ });
52
59
  } else {
53
60
  this._updateTagAttr();
54
61
  }
@@ -114,7 +121,16 @@ function defineTag() {
114
121
  this._template.innerHTML = '<style>:host {display: block;width: 100%;height: 100%;overflow: hidden;opacity: 0;background:transparent;}</style>';
115
122
  }
116
123
  }
124
+ _genFallbackLink() {
125
+ if (this._isIOS) {
126
+ this._alink_fallback = "https://apps.apple.com/cn/app/%E7%82%B9%E7%82%B9-%E8%AF%AD%E9%9F%B3%E5%BC%80%E9%BB%91/id1449564746";
127
+ } else {
128
+ var packageName = "com.tuwan.yw";
129
+ this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
130
+ }
131
+ }
117
132
  _updateTagAttr() {
133
+ this._genFallbackLink();
118
134
  if (this._openAppTag) {
119
135
  this._openAppTag.setAttribute('appid', this.getAttribute('appid') || this._defaultAppid);
120
136
  this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
@@ -122,10 +138,8 @@ function defineTag() {
122
138
  // TODO: 如果设置了点点以外的appid,这里其实是有问题的,待后续更新优化
123
139
  if (this._isIOS) {
124
140
  this._alink.href = "com.tuwan.diandian://openPage";
125
- this._alink_fallback = "https://apps.apple.com/cn/app/%E7%82%B9%E7%82%B9-%E8%AF%AD%E9%9F%B3%E5%BC%80%E9%BB%91/id1449564746";
126
141
  } else {
127
142
  var packageName = "com.tuwan.yw";
128
- this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
129
143
  this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
130
144
  }
131
145
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taole/dev-helper",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "npx -y rimraf dist && rollup -c",