@taole/dev-helper 0.0.25 → 0.0.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/Tdiv/index.js +4 -3
- package/dist/open-diandian.umd.js +51 -13
- package/dist/tdiv.umd.js +4 -3
- package/open-diandian/index.js +51 -13
- package/package.json +1 -1
package/Tdiv/index.js
CHANGED
|
@@ -55,7 +55,7 @@ function calc(value, { usePx, viewportWidth, viewportUnit }) {
|
|
|
55
55
|
class Tdiv extends HTMLElement {
|
|
56
56
|
static get observedAttributes() {
|
|
57
57
|
return [
|
|
58
|
-
'_class', 'usePx', '_style', 'src', 'width', 'height', 'absolute',
|
|
58
|
+
'_class', 'usePx', '_style', 'src', 'width', 'height', 'absolute', 'fixed',
|
|
59
59
|
'top', 'left', 'right', 'bottom', 'zIndex', 'pointer', 'flex', 'column', 'center',
|
|
60
60
|
'text', 'color', 'radius', 'border', 'borderColor', 'srcMode', 'onClick', 'debug', 'viewportWidth', 'viewportUnit',
|
|
61
61
|
'dot9', 'dot9Border', 'bold'
|
|
@@ -122,6 +122,7 @@ class Tdiv extends HTMLElement {
|
|
|
122
122
|
const width = this._getAttr('width');
|
|
123
123
|
const height = this._getAttr('height');
|
|
124
124
|
const absolute = this._getAttr('absolute', 'boolean');
|
|
125
|
+
const fixed = this._getAttr('fixed', 'boolean');
|
|
125
126
|
const top = this._getAttr('top');
|
|
126
127
|
const left = this._getAttr('left');
|
|
127
128
|
const right = this._getAttr('right');
|
|
@@ -170,8 +171,8 @@ class Tdiv extends HTMLElement {
|
|
|
170
171
|
const heightStyle = `height: ${calc(height, calcOpt)};`;
|
|
171
172
|
layoutStyle += heightStyle;
|
|
172
173
|
}
|
|
173
|
-
if (absolute) {
|
|
174
|
-
layoutStyle += 'position: absolute;';
|
|
174
|
+
if (absolute || fixed) {
|
|
175
|
+
layoutStyle += fixed ? 'position: fixed;' : 'position: absolute;';
|
|
175
176
|
if (hasValue(left)) layoutStyle += `left: ${calc(left, calcOpt)};`;
|
|
176
177
|
if (hasValue(top)) layoutStyle += `top: ${calc(top, calcOpt)};`;
|
|
177
178
|
if (hasValue(right)) layoutStyle += `right: ${calc(right, calcOpt)};`;
|
|
@@ -6,16 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
const name = 'open-diandian';
|
|
8
8
|
// 测试使用open-diandain-app标签
|
|
9
|
+
// TODO: 后期可以考虑优化为根据域名自动选择appid
|
|
9
10
|
function defineTag() {
|
|
10
11
|
customElements.define(
|
|
11
12
|
"open-diandain-app",
|
|
12
13
|
class extends HTMLElement {
|
|
13
14
|
static get observedAttributes() {
|
|
14
|
-
return ['appid', 'extinfo'];
|
|
15
|
+
return ['appid', 'extinfo', 'fallback_link_ios', 'fallback_link_android'];
|
|
15
16
|
}
|
|
16
17
|
constructor() {
|
|
17
18
|
super();
|
|
18
19
|
this._defaultAppid = 'wx6cd4c28b58e8737f';// 点点开黑
|
|
20
|
+
this._txcAppid = 'wx0e4a6eed634134ce'; // 兔小铲
|
|
19
21
|
this._openAppTag = null;
|
|
20
22
|
this._template = null;
|
|
21
23
|
this._alink = null;
|
|
@@ -56,11 +58,11 @@
|
|
|
56
58
|
this.shadowRoot.appendChild(this._template.content);
|
|
57
59
|
console.log('open-diandian: wx-open-launch-app appended');
|
|
58
60
|
// 监听打开app失败的情况,跳转fallback链接
|
|
59
|
-
this._openAppTag.addEventListener('error', (e)=>{
|
|
61
|
+
this._openAppTag.addEventListener('error', (e) => {
|
|
60
62
|
var tmplnk = document.createElement("a");
|
|
61
63
|
tmplnk.href = this._alink_fallback;
|
|
62
64
|
tmplnk.click();
|
|
63
|
-
console.log('open-diandian: wx-open-launch-app error',this._alink_fallback);
|
|
65
|
+
console.log('open-diandian: wx-open-launch-app error', this._alink_fallback);
|
|
64
66
|
});
|
|
65
67
|
} else {
|
|
66
68
|
this._updateTagAttr();
|
|
@@ -128,11 +130,28 @@
|
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
_genFallbackLink() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
const isDianDian = this.getAttribute('appid') === this._defaultAppid;
|
|
134
|
+
const isTxc = this.getAttribute('appid') === this._txcAppid;
|
|
135
|
+
if (isDianDian) {
|
|
136
|
+
if (this._isIOS) {
|
|
137
|
+
if (this.appid)
|
|
138
|
+
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";
|
|
139
|
+
} else {
|
|
140
|
+
var packageName = "com.tuwan.yw";
|
|
141
|
+
this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
|
|
142
|
+
}
|
|
143
|
+
} else if (isTxc) {
|
|
144
|
+
if (this._isIOS) {
|
|
145
|
+
this._alink_fallback = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
|
|
146
|
+
} else {
|
|
147
|
+
this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=com.tuwan.txc";
|
|
148
|
+
}
|
|
133
149
|
} else {
|
|
134
|
-
|
|
135
|
-
|
|
150
|
+
if (this._isIOS) {
|
|
151
|
+
this._alink_fallback = this.getAttribute('fallback_link_ios');
|
|
152
|
+
} else {
|
|
153
|
+
this._alink_fallback = this.getAttribute('fallback_link_android');
|
|
154
|
+
}
|
|
136
155
|
}
|
|
137
156
|
}
|
|
138
157
|
_updateTagAttr() {
|
|
@@ -141,12 +160,31 @@
|
|
|
141
160
|
this._openAppTag.setAttribute('appid', this.getAttribute('appid') || this._defaultAppid);
|
|
142
161
|
this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
|
|
143
162
|
} else if (this._alink) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
163
|
+
const isDianDian = this.getAttribute('appid') === this._defaultAppid;
|
|
164
|
+
const isTxc = this.getAttribute('appid') === this._txcAppid;
|
|
165
|
+
if (isDianDian) {
|
|
166
|
+
if (this._isIOS) {
|
|
167
|
+
this._alink.href = "com.tuwan.diandian://openPage";
|
|
168
|
+
} else {
|
|
169
|
+
var packageName = "com.tuwan.yw";
|
|
170
|
+
this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
|
|
171
|
+
}
|
|
172
|
+
} else if (isTxc) {
|
|
173
|
+
if (this._isAndroid) {
|
|
174
|
+
this._alink.href = "tuxiaochan://diandain:8888/splash";
|
|
175
|
+
// setTimeout(() => {
|
|
176
|
+
// window.location.href = "market://details?id=com.tuwan.txc";
|
|
177
|
+
// setTimeout(() => {
|
|
178
|
+
// window.location.href =
|
|
179
|
+
// "https://sj.qq.com/myapp/detail.htm?apkName=com.tuwan.txc";
|
|
180
|
+
// }, 200);
|
|
181
|
+
// }, 200);
|
|
182
|
+
} else if (this._isIOS) { // ios 跳转appstore
|
|
183
|
+
// window.location.href = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
|
|
184
|
+
this._alink.href = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
|
|
185
|
+
} else {
|
|
186
|
+
this._alink.href = "https://sj.qq.com/myapp/detail.htm?apkName=com.tuwan.txc";
|
|
187
|
+
}
|
|
150
188
|
}
|
|
151
189
|
}
|
|
152
190
|
}
|
package/dist/tdiv.umd.js
CHANGED
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
class Tdiv extends HTMLElement {
|
|
140
140
|
static get observedAttributes() {
|
|
141
141
|
return [
|
|
142
|
-
'_class', 'usePx', '_style', 'src', 'width', 'height', 'absolute',
|
|
142
|
+
'_class', 'usePx', '_style', 'src', 'width', 'height', 'absolute', 'fixed',
|
|
143
143
|
'top', 'left', 'right', 'bottom', 'zIndex', 'pointer', 'flex', 'column', 'center',
|
|
144
144
|
'text', 'color', 'radius', 'border', 'borderColor', 'srcMode', 'onClick', 'debug', 'viewportWidth', 'viewportUnit',
|
|
145
145
|
'dot9', 'dot9Border', 'bold'
|
|
@@ -206,6 +206,7 @@
|
|
|
206
206
|
const width = this._getAttr('width');
|
|
207
207
|
const height = this._getAttr('height');
|
|
208
208
|
const absolute = this._getAttr('absolute', 'boolean');
|
|
209
|
+
const fixed = this._getAttr('fixed', 'boolean');
|
|
209
210
|
const top = this._getAttr('top');
|
|
210
211
|
const left = this._getAttr('left');
|
|
211
212
|
const right = this._getAttr('right');
|
|
@@ -254,8 +255,8 @@
|
|
|
254
255
|
const heightStyle = `height: ${calc(height, calcOpt)};`;
|
|
255
256
|
layoutStyle += heightStyle;
|
|
256
257
|
}
|
|
257
|
-
if (absolute) {
|
|
258
|
-
layoutStyle += 'position: absolute;';
|
|
258
|
+
if (absolute || fixed) {
|
|
259
|
+
layoutStyle += fixed ? 'position: fixed;' : 'position: absolute;';
|
|
259
260
|
if (hasValue(left)) layoutStyle += `left: ${calc(left, calcOpt)};`;
|
|
260
261
|
if (hasValue(top)) layoutStyle += `top: ${calc(top, calcOpt)};`;
|
|
261
262
|
if (hasValue(right)) layoutStyle += `right: ${calc(right, calcOpt)};`;
|
package/open-diandian/index.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
const name = 'open-diandian';
|
|
2
2
|
// 测试使用open-diandain-app标签
|
|
3
|
+
// TODO: 后期可以考虑优化为根据域名自动选择appid
|
|
3
4
|
function defineTag() {
|
|
4
5
|
customElements.define(
|
|
5
6
|
"open-diandain-app",
|
|
6
7
|
class extends HTMLElement {
|
|
7
8
|
static get observedAttributes() {
|
|
8
|
-
return ['appid', 'extinfo'];
|
|
9
|
+
return ['appid', 'extinfo', 'fallback_link_ios', 'fallback_link_android'];
|
|
9
10
|
}
|
|
10
11
|
constructor() {
|
|
11
12
|
super();
|
|
12
13
|
this._defaultAppid = 'wx6cd4c28b58e8737f';// 点点开黑
|
|
14
|
+
this._txcAppid = 'wx0e4a6eed634134ce'; // 兔小铲
|
|
13
15
|
this._openAppTag = null;
|
|
14
16
|
this._template = null;
|
|
15
17
|
this._alink = null;
|
|
@@ -50,11 +52,11 @@ function defineTag() {
|
|
|
50
52
|
this.shadowRoot.appendChild(this._template.content);
|
|
51
53
|
console.log('open-diandian: wx-open-launch-app appended');
|
|
52
54
|
// 监听打开app失败的情况,跳转fallback链接
|
|
53
|
-
this._openAppTag.addEventListener('error', (e)=>{
|
|
55
|
+
this._openAppTag.addEventListener('error', (e) => {
|
|
54
56
|
var tmplnk = document.createElement("a");
|
|
55
57
|
tmplnk.href = this._alink_fallback;
|
|
56
58
|
tmplnk.click();
|
|
57
|
-
console.log('open-diandian: wx-open-launch-app error',this._alink_fallback);
|
|
59
|
+
console.log('open-diandian: wx-open-launch-app error', this._alink_fallback);
|
|
58
60
|
});
|
|
59
61
|
} else {
|
|
60
62
|
this._updateTagAttr();
|
|
@@ -122,11 +124,28 @@ function defineTag() {
|
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
_genFallbackLink() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
const isDianDian = this.getAttribute('appid') === this._defaultAppid;
|
|
128
|
+
const isTxc = this.getAttribute('appid') === this._txcAppid;
|
|
129
|
+
if (isDianDian) {
|
|
130
|
+
if (this._isIOS) {
|
|
131
|
+
if (this.appid)
|
|
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
|
+
} else if (isTxc) {
|
|
138
|
+
if (this._isIOS) {
|
|
139
|
+
this._alink_fallback = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
|
|
140
|
+
} else {
|
|
141
|
+
this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=com.tuwan.txc";
|
|
142
|
+
}
|
|
127
143
|
} else {
|
|
128
|
-
|
|
129
|
-
|
|
144
|
+
if (this._isIOS) {
|
|
145
|
+
this._alink_fallback = this.getAttribute('fallback_link_ios');
|
|
146
|
+
} else {
|
|
147
|
+
this._alink_fallback = this.getAttribute('fallback_link_android');
|
|
148
|
+
}
|
|
130
149
|
}
|
|
131
150
|
}
|
|
132
151
|
_updateTagAttr() {
|
|
@@ -135,12 +154,31 @@ function defineTag() {
|
|
|
135
154
|
this._openAppTag.setAttribute('appid', this.getAttribute('appid') || this._defaultAppid);
|
|
136
155
|
this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
|
|
137
156
|
} else if (this._alink) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
const isDianDian = this.getAttribute('appid') === this._defaultAppid;
|
|
158
|
+
const isTxc = this.getAttribute('appid') === this._txcAppid;
|
|
159
|
+
if (isDianDian) {
|
|
160
|
+
if (this._isIOS) {
|
|
161
|
+
this._alink.href = "com.tuwan.diandian://openPage";
|
|
162
|
+
} else {
|
|
163
|
+
var packageName = "com.tuwan.yw";
|
|
164
|
+
this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
|
|
165
|
+
}
|
|
166
|
+
} else if (isTxc) {
|
|
167
|
+
if (this._isAndroid) {
|
|
168
|
+
this._alink.href = "tuxiaochan://diandain:8888/splash";
|
|
169
|
+
// setTimeout(() => {
|
|
170
|
+
// window.location.href = "market://details?id=com.tuwan.txc";
|
|
171
|
+
// setTimeout(() => {
|
|
172
|
+
// window.location.href =
|
|
173
|
+
// "https://sj.qq.com/myapp/detail.htm?apkName=com.tuwan.txc";
|
|
174
|
+
// }, 200);
|
|
175
|
+
// }, 200);
|
|
176
|
+
} else if (this._isIOS) { // ios 跳转appstore
|
|
177
|
+
// window.location.href = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
|
|
178
|
+
this._alink.href = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
|
|
179
|
+
} else {
|
|
180
|
+
this._alink.href = "https://sj.qq.com/myapp/detail.htm?apkName=com.tuwan.txc";
|
|
181
|
+
}
|
|
144
182
|
}
|
|
145
183
|
}
|
|
146
184
|
}
|