@taole/dev-helper 0.0.29 → 0.0.31

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.
@@ -1,10 +1,9 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
1
+ (function (factory) {
3
2
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.OpenDiandian = factory());
5
- })(this, (function () { 'use strict';
3
+ factory();
4
+ })((function () { 'use strict';
6
5
 
7
- const name = 'open-diandian';
6
+ // const name = 'open-diandian';
8
7
  // 测试使用open-diandain-app标签
9
8
  // TODO: 后期可以考虑优化为根据域名自动选择appid
10
9
  function defineTag() {
@@ -26,7 +25,8 @@
26
25
  this._isWechat = /MicroMessenger/i.test(navigator.userAgent);
27
26
  this._isAndroid = /Android/i.test(navigator.userAgent);
28
27
  this._isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
29
- this._isMobile = this._isAndroid || this._isIOS;
28
+ this._isHarmony = /Harmony/i.test(navigator.userAgent);
29
+ this._isMobile = this._isAndroid || this._isIOS || this._isHarmony;
30
30
  }
31
31
  attributeChangedCallback() {
32
32
  this._updateTagAttr();
@@ -60,6 +60,10 @@
60
60
  console.log('open-diandian: wx-open-launch-app appended');
61
61
  // 监听打开app失败的情况,跳转fallback链接
62
62
  this._openAppTag.addEventListener('error', (e) => {
63
+ if (this._isHarmony) {
64
+ this._showOpenInBrowserHint();
65
+ return;
66
+ }
63
67
  var tmplnk = document.createElement("a");
64
68
  tmplnk.href = this._alink_fallback;
65
69
  tmplnk.click();
@@ -80,6 +84,10 @@
80
84
  this.shadowRoot.appendChild(this._template.content);
81
85
  this._alink.addEventListener('click', this._handleAlinkClick.bind(this));
82
86
  console.log('open-diandian: open link appended');
87
+ // only test
88
+ // if(this._isHarmony){
89
+ // this._showOpenInBrowserHint();
90
+ // }
83
91
  }
84
92
  this._updateTagAttr();
85
93
  }
@@ -101,6 +109,34 @@
101
109
  this._alink = null;
102
110
  }
103
111
  }
112
+ _showOpenInBrowserHint() { // 提示用户在浏览器中打开
113
+ console.log('open-diandian: showOpenInBrowserHint');
114
+ let _hHintDiv = document.getElementById('open-diandian-h-hint-div');
115
+ if(_hHintDiv){
116
+ _hHintDiv.remove();
117
+ _hHintDiv = null;
118
+ }
119
+ // https://asset.tuwan.com/images/llqdk.png
120
+ _hHintDiv = document.createElement('div');
121
+ _hHintDiv.id = 'open-diandian-h-hint-div';
122
+ _hHintDiv.style.position = 'fixed';
123
+ _hHintDiv.style.top = '0';
124
+ _hHintDiv.style.left = '0';
125
+ _hHintDiv.style.width = '100%';
126
+ _hHintDiv.style.height = '100%';
127
+ _hHintDiv.style.zIndex = '100000';
128
+ _hHintDiv.style.backgroundImage = 'url(https://asset.tuwan.com/images/llqdk.png)';
129
+ _hHintDiv.style.backgroundRepeat = 'no-repeat';
130
+ _hHintDiv.style.backgroundSize = '80vw auto';
131
+ _hHintDiv.style.backgroundPosition = 'top right';
132
+ _hHintDiv.style.backgroundColor = 'rgba(0,0,0,0.5)';
133
+ _hHintDiv.onclick = function() {
134
+ _hHintDiv.remove();
135
+ _hHintDiv = null;
136
+ };
137
+ this._hHintDiv = _hHintDiv;
138
+ document.body.appendChild(this._hHintDiv);
139
+ }
104
140
  _genTemplate() {
105
141
  if (!this._template) {
106
142
  this._template = document.createElement('template');
@@ -148,7 +184,7 @@
148
184
  this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
149
185
  }
150
186
  } else if (isTxc) {
151
- if (this._isAndroid) {
187
+ if (this._isAndroid || this._isHarmony) {
152
188
  this._alink.href = "tuxiaochan://diandain:8888/splash";
153
189
  } else if (this._isIOS) { // ios 跳转appstore
154
190
  this._alink.href = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
@@ -172,10 +208,8 @@
172
208
 
173
209
  registerTdiv();
174
210
 
175
- var index = {
176
- name
177
- };
178
-
179
- return index;
211
+ // export default {
212
+ // name
213
+ // }
180
214
 
181
215
  }));
@@ -1,4 +1,4 @@
1
- const name = 'open-diandian';
1
+ // const name = 'open-diandian';
2
2
  // 测试使用open-diandain-app标签
3
3
  // TODO: 后期可以考虑优化为根据域名自动选择appid
4
4
  function defineTag() {
@@ -20,7 +20,8 @@ function defineTag() {
20
20
  this._isWechat = /MicroMessenger/i.test(navigator.userAgent);
21
21
  this._isAndroid = /Android/i.test(navigator.userAgent);
22
22
  this._isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
23
- this._isMobile = this._isAndroid || this._isIOS;
23
+ this._isHarmony = /Harmony/i.test(navigator.userAgent);
24
+ this._isMobile = this._isAndroid || this._isIOS || this._isHarmony;
24
25
  }
25
26
  attributeChangedCallback() {
26
27
  this._updateTagAttr();
@@ -54,6 +55,10 @@ function defineTag() {
54
55
  console.log('open-diandian: wx-open-launch-app appended');
55
56
  // 监听打开app失败的情况,跳转fallback链接
56
57
  this._openAppTag.addEventListener('error', (e) => {
58
+ if (this._isHarmony) {
59
+ this._showOpenInBrowserHint();
60
+ return;
61
+ }
57
62
  var tmplnk = document.createElement("a");
58
63
  tmplnk.href = this._alink_fallback;
59
64
  tmplnk.click();
@@ -74,6 +79,10 @@ function defineTag() {
74
79
  this.shadowRoot.appendChild(this._template.content);
75
80
  this._alink.addEventListener('click', this._handleAlinkClick.bind(this));
76
81
  console.log('open-diandian: open link appended');
82
+ // only test
83
+ // if(this._isHarmony){
84
+ // this._showOpenInBrowserHint();
85
+ // }
77
86
  }
78
87
  this._updateTagAttr();
79
88
  }
@@ -95,6 +104,34 @@ function defineTag() {
95
104
  this._alink = null;
96
105
  }
97
106
  }
107
+ _showOpenInBrowserHint() { // 提示用户在浏览器中打开
108
+ console.log('open-diandian: showOpenInBrowserHint');
109
+ let _hHintDiv = document.getElementById('open-diandian-h-hint-div');
110
+ if(_hHintDiv){
111
+ _hHintDiv.remove();
112
+ _hHintDiv = null;
113
+ }
114
+ // https://asset.tuwan.com/images/llqdk.png
115
+ _hHintDiv = document.createElement('div');
116
+ _hHintDiv.id = 'open-diandian-h-hint-div';
117
+ _hHintDiv.style.position = 'fixed';
118
+ _hHintDiv.style.top = '0';
119
+ _hHintDiv.style.left = '0';
120
+ _hHintDiv.style.width = '100%';
121
+ _hHintDiv.style.height = '100%';
122
+ _hHintDiv.style.zIndex = '100000';
123
+ _hHintDiv.style.backgroundImage = 'url(https://asset.tuwan.com/images/llqdk.png)';
124
+ _hHintDiv.style.backgroundRepeat = 'no-repeat';
125
+ _hHintDiv.style.backgroundSize = '80vw auto';
126
+ _hHintDiv.style.backgroundPosition = 'top right';
127
+ _hHintDiv.style.backgroundColor = 'rgba(0,0,0,0.5)';
128
+ _hHintDiv.onclick = function() {
129
+ _hHintDiv.remove();
130
+ _hHintDiv = null;
131
+ };
132
+ this._hHintDiv = _hHintDiv;
133
+ document.body.appendChild(this._hHintDiv);
134
+ }
98
135
  _genTemplate() {
99
136
  if (!this._template) {
100
137
  this._template = document.createElement('template');
@@ -142,7 +179,7 @@ function defineTag() {
142
179
  this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
143
180
  }
144
181
  } else if (isTxc) {
145
- if (this._isAndroid) {
182
+ if (this._isAndroid || this._isHarmony) {
146
183
  this._alink.href = "tuxiaochan://diandain:8888/splash";
147
184
  } else if (this._isIOS) { // ios 跳转appstore
148
185
  this._alink.href = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
@@ -166,6 +203,6 @@ function registerTdiv() {
166
203
 
167
204
  registerTdiv();
168
205
 
169
- export default {
170
- name
171
- }
206
+ // export default {
207
+ // name
208
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taole/dev-helper",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "npx -y rimraf dist && rollup -c",