@taole/dev-helper 0.1.0 → 0.1.1
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 +32 -9
- package/open-diandian/index.js +32 -9
- package/package.json +1 -1
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
'wxcd28679e4d8c1792': { // 点点狼人
|
|
24
24
|
app_name: '点点狼人',
|
|
25
25
|
link_ios: "", // 空缺,后期补充
|
|
26
|
-
link_android: "
|
|
26
|
+
link_android: "taole://diandainwolf:8888/splash",
|
|
27
27
|
fallback_link_ios: 'https://apps.apple.com/mo/app/%E7%82%B9%E7%82%B9%E7%8B%BC%E4%BA%BA%E6%9D%80-%E8%AF%AD%E9%9F%B3%E7%A4%BE%E4%BA%A4%E6%8E%A8%E7%90%86%E6%B8%B8%E6%88%8F/id1557616226',
|
|
28
28
|
fallback_link_android: '',
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
|
-
function resolveTwKit(){
|
|
32
|
-
if(window.twKit){
|
|
31
|
+
function resolveTwKit() {
|
|
32
|
+
if (window.twKit) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const script = document.createElement('script');
|
|
@@ -139,6 +139,21 @@
|
|
|
139
139
|
this.shadowRoot.appendChild(this._template.content);
|
|
140
140
|
this._alink.addEventListener('click', this._handleAlinkClick.bind(this));
|
|
141
141
|
this._log('open-diandian: open link appended');
|
|
142
|
+
this._clickLink = false;
|
|
143
|
+
this._pagehideCallback = this._pagehideCallback || (() => {
|
|
144
|
+
if (document.hidden) {
|
|
145
|
+
if (this._clickLink) {
|
|
146
|
+
this._log("open app successfully");
|
|
147
|
+
if (this._alink_click_timer) {
|
|
148
|
+
clearTimeout(this._alink_click_timer);
|
|
149
|
+
this._alink_click_timer = null;
|
|
150
|
+
}
|
|
151
|
+
this._clickLink = false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
window.removeEventListener("visibilitychange", this._pagehideCallback);
|
|
156
|
+
window.addEventListener("visibilitychange", this._pagehideCallback);
|
|
142
157
|
}
|
|
143
158
|
this._updateTagAttr();
|
|
144
159
|
this._initClipboardText();
|
|
@@ -149,11 +164,19 @@
|
|
|
149
164
|
_handleAlinkClick() {
|
|
150
165
|
this._writeClickboard();
|
|
151
166
|
if (this._alink_link != this._alink_fallback) {
|
|
152
|
-
|
|
167
|
+
this._log("this._alink is clicked");
|
|
168
|
+
// 端外使用scheme打开app,3秒内如果页面有隐藏过,那么认为拉端成功了,否则跳转到fallback链接
|
|
169
|
+
if (this._alink_click_timer) {
|
|
170
|
+
clearTimeout(this._alink_click_timer);
|
|
171
|
+
}
|
|
172
|
+
this._clickLink = true;
|
|
173
|
+
this._alink_click_timer = setTimeout(() => {
|
|
174
|
+
this._log("3s timeout, open app failed, jump to fallback link");
|
|
175
|
+
this._alink_click_timer = null;
|
|
153
176
|
var tmplnk = document.createElement("a");
|
|
154
177
|
tmplnk.href = this._alink_fallback;
|
|
155
178
|
tmplnk.click();
|
|
156
|
-
},
|
|
179
|
+
}, 3000);
|
|
157
180
|
}
|
|
158
181
|
}
|
|
159
182
|
disconnectedCallback() {
|
|
@@ -171,17 +194,17 @@
|
|
|
171
194
|
_initClipboardText() {
|
|
172
195
|
// 延迟20ms执行,如果20ms后卸载了,直接不执行了
|
|
173
196
|
this._clipboardTextTimer = setTimeout(() => {
|
|
174
|
-
if(!this._isConnected){
|
|
197
|
+
if (!this._isConnected) {
|
|
175
198
|
this._log("not connected, no need to init clipboard text");
|
|
176
199
|
return;
|
|
177
200
|
}
|
|
178
201
|
const extinfo = this.getAttribute('extinfo') || '';
|
|
179
|
-
if(!extinfo){
|
|
202
|
+
if (!extinfo) {
|
|
180
203
|
this._log("extinfo is empty, no need to init clipboard text");
|
|
181
204
|
return;
|
|
182
205
|
}
|
|
183
206
|
this._log("initClipboardText");
|
|
184
|
-
if(!this._clipboardTextPs){
|
|
207
|
+
if (!this._clipboardTextPs) {
|
|
185
208
|
this._clipboardTextPs = new Promise(async (resolve, reject) => {
|
|
186
209
|
try {
|
|
187
210
|
await resolveTwKit();
|
|
@@ -200,7 +223,7 @@
|
|
|
200
223
|
}
|
|
201
224
|
async _writeClickboard() {
|
|
202
225
|
const text = this._clipboardText;
|
|
203
|
-
if(!text){
|
|
226
|
+
if (!text) {
|
|
204
227
|
this._log("clipboard text is empty, no need to write clipboard");
|
|
205
228
|
return;
|
|
206
229
|
}
|
package/open-diandian/index.js
CHANGED
|
@@ -18,13 +18,13 @@ const appInfoMap = {
|
|
|
18
18
|
'wxcd28679e4d8c1792': { // 点点狼人
|
|
19
19
|
app_name: '点点狼人',
|
|
20
20
|
link_ios: "", // 空缺,后期补充
|
|
21
|
-
link_android: "
|
|
21
|
+
link_android: "taole://diandainwolf:8888/splash",
|
|
22
22
|
fallback_link_ios: 'https://apps.apple.com/mo/app/%E7%82%B9%E7%82%B9%E7%8B%BC%E4%BA%BA%E6%9D%80-%E8%AF%AD%E9%9F%B3%E7%A4%BE%E4%BA%A4%E6%8E%A8%E7%90%86%E6%B8%B8%E6%88%8F/id1557616226',
|
|
23
23
|
fallback_link_android: '',
|
|
24
24
|
},
|
|
25
25
|
}
|
|
26
|
-
function resolveTwKit(){
|
|
27
|
-
if(window.twKit){
|
|
26
|
+
function resolveTwKit() {
|
|
27
|
+
if (window.twKit) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const script = document.createElement('script');
|
|
@@ -134,6 +134,21 @@ function defineTag() {
|
|
|
134
134
|
this.shadowRoot.appendChild(this._template.content);
|
|
135
135
|
this._alink.addEventListener('click', this._handleAlinkClick.bind(this));
|
|
136
136
|
this._log('open-diandian: open link appended');
|
|
137
|
+
this._clickLink = false;
|
|
138
|
+
this._pagehideCallback = this._pagehideCallback || (() => {
|
|
139
|
+
if (document.hidden) {
|
|
140
|
+
if (this._clickLink) {
|
|
141
|
+
this._log("open app successfully");
|
|
142
|
+
if (this._alink_click_timer) {
|
|
143
|
+
clearTimeout(this._alink_click_timer);
|
|
144
|
+
this._alink_click_timer = null;
|
|
145
|
+
}
|
|
146
|
+
this._clickLink = false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
window.removeEventListener("visibilitychange", this._pagehideCallback);
|
|
151
|
+
window.addEventListener("visibilitychange", this._pagehideCallback);
|
|
137
152
|
}
|
|
138
153
|
this._updateTagAttr();
|
|
139
154
|
this._initClipboardText();
|
|
@@ -144,11 +159,19 @@ function defineTag() {
|
|
|
144
159
|
_handleAlinkClick() {
|
|
145
160
|
this._writeClickboard();
|
|
146
161
|
if (this._alink_link != this._alink_fallback) {
|
|
147
|
-
|
|
162
|
+
this._log("this._alink is clicked");
|
|
163
|
+
// 端外使用scheme打开app,3秒内如果页面有隐藏过,那么认为拉端成功了,否则跳转到fallback链接
|
|
164
|
+
if (this._alink_click_timer) {
|
|
165
|
+
clearTimeout(this._alink_click_timer);
|
|
166
|
+
}
|
|
167
|
+
this._clickLink = true;
|
|
168
|
+
this._alink_click_timer = setTimeout(() => {
|
|
169
|
+
this._log("3s timeout, open app failed, jump to fallback link");
|
|
170
|
+
this._alink_click_timer = null;
|
|
148
171
|
var tmplnk = document.createElement("a");
|
|
149
172
|
tmplnk.href = this._alink_fallback;
|
|
150
173
|
tmplnk.click();
|
|
151
|
-
},
|
|
174
|
+
}, 3000);
|
|
152
175
|
}
|
|
153
176
|
}
|
|
154
177
|
disconnectedCallback() {
|
|
@@ -166,17 +189,17 @@ function defineTag() {
|
|
|
166
189
|
_initClipboardText() {
|
|
167
190
|
// 延迟20ms执行,如果20ms后卸载了,直接不执行了
|
|
168
191
|
this._clipboardTextTimer = setTimeout(() => {
|
|
169
|
-
if(!this._isConnected){
|
|
192
|
+
if (!this._isConnected) {
|
|
170
193
|
this._log("not connected, no need to init clipboard text")
|
|
171
194
|
return;
|
|
172
195
|
}
|
|
173
196
|
const extinfo = this.getAttribute('extinfo') || '';
|
|
174
|
-
if(!extinfo){
|
|
197
|
+
if (!extinfo) {
|
|
175
198
|
this._log("extinfo is empty, no need to init clipboard text")
|
|
176
199
|
return;
|
|
177
200
|
}
|
|
178
201
|
this._log("initClipboardText")
|
|
179
|
-
if(!this._clipboardTextPs){
|
|
202
|
+
if (!this._clipboardTextPs) {
|
|
180
203
|
this._clipboardTextPs = new Promise(async (resolve, reject) => {
|
|
181
204
|
try {
|
|
182
205
|
await resolveTwKit();
|
|
@@ -195,7 +218,7 @@ function defineTag() {
|
|
|
195
218
|
}
|
|
196
219
|
async _writeClickboard() {
|
|
197
220
|
const text = this._clipboardText;
|
|
198
|
-
if(!text){
|
|
221
|
+
if (!text) {
|
|
199
222
|
this._log("clipboard text is empty, no need to write clipboard")
|
|
200
223
|
return;
|
|
201
224
|
}
|