@taole/dev-helper 0.0.25 → 0.0.27

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 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,19 @@
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
+ // 后期考虑去掉fallback_link_ios和fallback_link_android
16
+ return ['appid', 'extinfo', 'fallback_link_ios', 'fallback_link_android'];
15
17
  }
16
18
  constructor() {
17
19
  super();
18
20
  this._defaultAppid = 'wx6cd4c28b58e8737f';// 点点开黑
21
+ this._txcAppid = 'wx0e4a6eed634134ce'; // 兔小铲
19
22
  this._openAppTag = null;
20
23
  this._template = null;
21
24
  this._alink = null;
@@ -56,11 +59,11 @@
56
59
  this.shadowRoot.appendChild(this._template.content);
57
60
  console.log('open-diandian: wx-open-launch-app appended');
58
61
  // 监听打开app失败的情况,跳转fallback链接
59
- this._openAppTag.addEventListener('error', (e)=>{
62
+ this._openAppTag.addEventListener('error', (e) => {
60
63
  var tmplnk = document.createElement("a");
61
64
  tmplnk.href = this._alink_fallback;
62
65
  tmplnk.click();
63
- console.log('open-diandian: wx-open-launch-app error',this._alink_fallback);
66
+ console.log('open-diandian: wx-open-launch-app error', this._alink_fallback);
64
67
  });
65
68
  } else {
66
69
  this._updateTagAttr();
@@ -128,11 +131,28 @@
128
131
  }
129
132
  }
130
133
  _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";
134
+ const isDianDian = this.getAttribute('appid') === this._defaultAppid;
135
+ const isTxc = this.getAttribute('appid') === this._txcAppid;
136
+ if (isDianDian) {
137
+ if (this._isIOS) {
138
+ if (this.appid)
139
+ 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";
140
+ } else {
141
+ var packageName = "com.tuwan.yw";
142
+ this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
143
+ }
144
+ } else if (isTxc) {
145
+ if (this._isIOS) {
146
+ this._alink_fallback = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
147
+ } else {
148
+ this._alink_fallback = "https://m.malink.cn/s/rYNfAj";
149
+ }
133
150
  } else {
134
- var packageName = "com.tuwan.yw";
135
- this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
151
+ if (this._isIOS) {
152
+ this._alink_fallback = this.getAttribute('fallback_link_ios');
153
+ } else {
154
+ this._alink_fallback = this.getAttribute('fallback_link_android');
155
+ }
136
156
  }
137
157
  }
138
158
  _updateTagAttr() {
@@ -141,12 +161,23 @@
141
161
  this._openAppTag.setAttribute('appid', this.getAttribute('appid') || this._defaultAppid);
142
162
  this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
143
163
  } else if (this._alink) {
144
- // TODO: 如果设置了点点以外的appid,这里其实是有问题的,待后续更新优化
145
- if (this._isIOS) {
146
- this._alink.href = "com.tuwan.diandian://openPage";
147
- } else {
148
- var packageName = "com.tuwan.yw";
149
- this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
164
+ const isDianDian = this.getAttribute('appid') === this._defaultAppid;
165
+ const isTxc = this.getAttribute('appid') === this._txcAppid;
166
+ if (isDianDian) {
167
+ if (this._isIOS) {
168
+ this._alink.href = "com.tuwan.diandian://openPage";
169
+ } else {
170
+ var packageName = "com.tuwan.yw";
171
+ this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
172
+ }
173
+ } else if (isTxc) {
174
+ if (this._isAndroid) {
175
+ this._alink.href = "tuxiaochan://diandain:8888/splash";
176
+ } else if (this._isIOS) { // ios 跳转appstore
177
+ this._alink.href = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
178
+ } else {
179
+ this._alink.href = "https://m.malink.cn/s/rYNfAj";
180
+ }
150
181
  }
151
182
  }
152
183
  }
@@ -164,7 +195,6 @@
164
195
 
165
196
  registerTdiv();
166
197
 
167
- // TODO: 之后放出setting入口之类的
168
198
  var index = {
169
199
  name
170
200
  };
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)};`;
@@ -1,15 +1,18 @@
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
+ // 后期考虑去掉fallback_link_ios和fallback_link_android
10
+ return ['appid', 'extinfo', 'fallback_link_ios', 'fallback_link_android'];
9
11
  }
10
12
  constructor() {
11
13
  super();
12
14
  this._defaultAppid = 'wx6cd4c28b58e8737f';// 点点开黑
15
+ this._txcAppid = 'wx0e4a6eed634134ce'; // 兔小铲
13
16
  this._openAppTag = null;
14
17
  this._template = null;
15
18
  this._alink = null;
@@ -50,11 +53,11 @@ function defineTag() {
50
53
  this.shadowRoot.appendChild(this._template.content);
51
54
  console.log('open-diandian: wx-open-launch-app appended');
52
55
  // 监听打开app失败的情况,跳转fallback链接
53
- this._openAppTag.addEventListener('error', (e)=>{
56
+ this._openAppTag.addEventListener('error', (e) => {
54
57
  var tmplnk = document.createElement("a");
55
58
  tmplnk.href = this._alink_fallback;
56
59
  tmplnk.click();
57
- console.log('open-diandian: wx-open-launch-app error',this._alink_fallback);
60
+ console.log('open-diandian: wx-open-launch-app error', this._alink_fallback);
58
61
  });
59
62
  } else {
60
63
  this._updateTagAttr();
@@ -122,11 +125,28 @@ function defineTag() {
122
125
  }
123
126
  }
124
127
  _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";
128
+ const isDianDian = this.getAttribute('appid') === this._defaultAppid;
129
+ const isTxc = this.getAttribute('appid') === this._txcAppid;
130
+ if (isDianDian) {
131
+ if (this._isIOS) {
132
+ if (this.appid)
133
+ 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";
134
+ } else {
135
+ var packageName = "com.tuwan.yw";
136
+ this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
137
+ }
138
+ } else if (isTxc) {
139
+ if (this._isIOS) {
140
+ this._alink_fallback = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
141
+ } else {
142
+ this._alink_fallback = "https://m.malink.cn/s/rYNfAj";
143
+ }
127
144
  } else {
128
- var packageName = "com.tuwan.yw";
129
- this._alink_fallback = "https://sj.qq.com/myapp/detail.htm?apkName=" + packageName;
145
+ if (this._isIOS) {
146
+ this._alink_fallback = this.getAttribute('fallback_link_ios');
147
+ } else {
148
+ this._alink_fallback = this.getAttribute('fallback_link_android');
149
+ }
130
150
  }
131
151
  }
132
152
  _updateTagAttr() {
@@ -135,12 +155,23 @@ function defineTag() {
135
155
  this._openAppTag.setAttribute('appid', this.getAttribute('appid') || this._defaultAppid);
136
156
  this._openAppTag.setAttribute('extinfo', this.getAttribute('extinfo') || "");
137
157
  } else if (this._alink) {
138
- // TODO: 如果设置了点点以外的appid,这里其实是有问题的,待后续更新优化
139
- if (this._isIOS) {
140
- this._alink.href = "com.tuwan.diandian://openPage";
141
- } else {
142
- var packageName = "com.tuwan.yw";
143
- this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
158
+ const isDianDian = this.getAttribute('appid') === this._defaultAppid;
159
+ const isTxc = this.getAttribute('appid') === this._txcAppid;
160
+ if (isDianDian) {
161
+ if (this._isIOS) {
162
+ this._alink.href = "com.tuwan.diandian://openPage";
163
+ } else {
164
+ var packageName = "com.tuwan.yw";
165
+ this._alink.href = "intent://diandain:8888/splash#Intent;scheme=taole;package=" + packageName + ";S.browser_fallback_url=" + this._alink_fallback + ";end";
166
+ }
167
+ } else if (isTxc) {
168
+ if (this._isAndroid) {
169
+ this._alink.href = "tuxiaochan://diandain:8888/splash";
170
+ } else if (this._isIOS) { // ios 跳转appstore
171
+ this._alink.href = 'https://apps.apple.com/us/app/%E5%85%94%E5%B0%8F%E9%93%B2/id6745920939';
172
+ } else {
173
+ this._alink.href = "https://m.malink.cn/s/rYNfAj";
174
+ }
144
175
  }
145
176
  }
146
177
  }
@@ -158,7 +189,6 @@ function registerTdiv() {
158
189
 
159
190
  registerTdiv();
160
191
 
161
- // TODO: 之后放出setting入口之类的
162
192
  export default {
163
193
  name
164
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taole/dev-helper",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "npx -y rimraf dist && rollup -c",