@solar-taro/ui-vant 3.4.2 → 3.5.0

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/index7.js CHANGED
@@ -1,13 +1,13 @@
1
- import { defineComponent as J, ref as I, computed as Q, watch as X, onUnmounted as Y, unref as Z, createElementVNode as ee, toDisplayString as te, vShow as ne, withDirectives as oe, normalizeClass as ie, createTextVNode as se, Fragment as re, openBlock as le, createElementBlock as ce, renderList as ae, normalizeStyle as ue, withCtx as de, createVNode as pe } from "vue";
2
- import { isOpperDevice as ve } from "@opper/core";
3
- import { BluetoothLowEnergeyDevice as me } from "@opper/wx";
4
- import { checkBluetooth as V, bluetoothService as w, vibrator as fe, overlay as r, withLoading as we } from "@solar-taro/core";
5
- import { SunList as he } from "@solar-taro/ui-sun";
1
+ import { defineComponent as Q, ref as x, computed as X, watch as Y, onUnmounted as Z, unref as ee, createElementVNode as te, toDisplayString as ne, createVNode as oe, vShow as se, withDirectives as ie, normalizeClass as re, createTextVNode as le, Fragment as ce, openBlock as ae, createElementBlock as ue, renderList as de, normalizeStyle as pe, withCtx as ve } from "vue";
2
+ import { isOpperDevice as me } from "@opper/core";
3
+ import { BluetoothLowEnergeyDevice as fe } from "@opper/wx";
4
+ import { checkBluetooth as V, bluetoothService as w, vibrator as we, overlay as r, withLoading as he } from "@solar-taro/core";
5
+ import { SunIcon as be, SunList as ge } from "@solar-taro/ui-sun";
6
6
  import { useDestroyed as A, useObservable as j } from "@solar-vue/core";
7
- import { getSystemInfo as be, openSetting as ge } from "@tarojs/taro";
8
- import { filter as F, switchMap as m, combineLatest as ye, of as E, map as $, catchError as D, tap as B, timer as _e, takeUntil as N, finalize as O, from as De } from "rxjs";
9
- import { dialog as Se } from "./index14.js";
10
- const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le, b = ce, Ee = ae, $e = ue, Be = de, Ne = pe, Oe = { class: "sun-opper-controller" }, Te = ["show"], Le = { class: "sun-opper-controller-device" }, Me = { class: "sun-opper-controller-device-header" }, Pe = { class: "sun-opper-controller-device-name" }, Re = { class: "sun-opper-controller-device-infos" }, ze = { class: "sun-opper-controller-device-info" }, Ve = { class: "sun-opper-controller-device-info" }, Ae = { class: "sun-opper-controller-device-info" }, je = { class: "sun-opper-controller-device-info" }, Fe = { class: "van-button-container" }, Ue = ["title", "label", "onTap"], qe = { class: "van-button-container" }, Ke = ["show"], tt = /* @__PURE__ */ J({
7
+ import { getSystemInfo as ye, openSetting as _e } from "@tarojs/taro";
8
+ import { filter as F, switchMap as m, combineLatest as De, of as E, map as $, catchError as D, tap as B, timer as Se, takeUntil as N, finalize as O, from as Ce } from "rxjs";
9
+ import { dialog as ke } from "./index14.js";
10
+ const l = ee, n = te, p = ne, U = oe, Ie = se, xe = ie, Ee = re, $e = le, T = ce, h = ae, b = ue, Be = de, Ne = pe, Oe = ve, Te = { class: "sun-opper-controller" }, Le = ["show"], Me = { class: "sun-opper-controller-device" }, Pe = { class: "sun-opper-controller-device-header" }, Re = { class: "sun-opper-controller-device-name" }, ze = { class: "sun-opper-controller-device-infos" }, Ve = { class: "sun-opper-controller-device-info" }, Ae = { class: "sun-opper-controller-device-info" }, je = { class: "sun-opper-controller-device-info" }, Fe = { class: "sun-opper-controller-device-info" }, Ue = { class: "van-button-container" }, qe = ["title", "label", "onTap"], Ke = { class: "van-button-container" }, We = ["show"], nt = /* @__PURE__ */ Q({
11
11
  __name: "index",
12
12
  props: {
13
13
  show: { type: Boolean, default: !1 },
@@ -16,31 +16,31 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
16
16
  opper: {}
17
17
  },
18
18
  emits: ["update:show", "connect", "disconnect"],
19
- setup(U, { emit: q }) {
20
- const v = U, S = q, s = v.opper, L = A(), C = A(), a = I({}), u = I(!1), M = j(() => s.connected), g = I(!1), P = Q(() => Object.values(a.value)), d = j(() => s.connected.pipe(
19
+ setup(q, { emit: K }) {
20
+ const v = q, S = K, i = v.opper, L = A(), C = A(), a = x({}), u = x(!1), M = j(() => i.connected), g = x(!1), P = X(() => Object.values(a.value)), d = j(() => i.connected.pipe(
21
21
  F(Boolean),
22
22
  m(() => {
23
- const o = s.device;
24
- return ye({
23
+ const o = i.device;
24
+ return De({
25
25
  id: E(o.id),
26
26
  name: o.name,
27
27
  version: o.firmwareRevision,
28
- accuracy: s.accuracyChange,
29
- volt: s.batteryChange.pipe(
28
+ accuracy: i.accuracyChange,
29
+ volt: i.batteryChange.pipe(
30
30
  $(([e]) => e)
31
31
  ),
32
- charging: s.batteryChange.pipe(
32
+ charging: i.batteryChange.pipe(
33
33
  $(([, e]) => !!e)
34
34
  ),
35
35
  serialNumber: o.serialNumber
36
36
  });
37
37
  })
38
- ), {}), K = [
38
+ ), {}), W = [
39
39
  { id: 1, name: "断开连接" },
40
40
  { id: 2, name: "断开连接并关机", color: "var(--color-danger)" }
41
41
  ];
42
42
  let k = !1;
43
- function x() {
43
+ function I() {
44
44
  if (!V()) return;
45
45
  let o = null;
46
46
  u.value = !0, w.openAdapter().pipe(
@@ -57,21 +57,21 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
57
57
  })
58
58
  ),
59
59
  B(
60
- () => _e(0, 1250).pipe(
60
+ () => Se(0, 1250).pipe(
61
61
  N(C)
62
- ).subscribe(() => fe.short())
62
+ ).subscribe(() => we.short())
63
63
  ),
64
64
  m(() => w.devicesChange),
65
- $((e) => e.filter((t) => ve({
65
+ $((e) => e.filter((t) => me({
66
66
  id: t.deviceId,
67
67
  name: t.name
68
68
  }))),
69
69
  N(C),
70
70
  D((e) => {
71
- var t, c, i;
71
+ var t, c, s;
72
72
  throw e.errno === 103 ? r.modal("温馨提示", "请先授予小程序蓝牙与位置权限").then(() => {
73
- ge();
74
- }) : (c = (t = e.errMsg) == null ? void 0 : t.includes) != null && c.call(t, "permission") ? r.tips("请先授予微信蓝牙与位置权限") : (i = e.errMsg) != null && i.includes("frequently") ? r.tips("操作频繁,请稍后再试") : r.tips(e.errMsg), f(), e;
73
+ _e();
74
+ }) : (c = (t = e.errMsg) == null ? void 0 : t.includes) != null && c.call(t, "permission") ? r.tips("请先授予微信蓝牙与位置权限") : (s = e.errMsg) != null && s.includes("frequently") ? r.tips("操作频繁,请稍后再试") : r.tips(e.errMsg), f(), e;
75
75
  }),
76
76
  O(() => {
77
77
  u.value = !1, a.value = {}, w.stopDevicesDiscovery().subscribe();
@@ -79,9 +79,9 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
79
79
  ).subscribe((e) => {
80
80
  const t = v.mac || v.deviceId;
81
81
  if (t) {
82
- const i = t.slice(-5).replace(":", ""), _ = e.find(
82
+ const s = t.slice(-5).replace(":", ""), _ = e.find(
83
83
  (z) => z.deviceId === t || // 由于 iOS 的 deviceId 不是 MAC,但是蓝牙名字上有 MAC 后四位,这里通过比对 MAC 来选择设备
84
- z.name.endsWith(i)
84
+ z.name.endsWith(s)
85
85
  );
86
86
  if (_)
87
87
  return y(_.deviceId);
@@ -90,12 +90,12 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
90
90
  if (o != null || (o = Date.now()), Date.now() - o > 5e3)
91
91
  return y(e[0].deviceId);
92
92
  } else e.length > 1 && (o = null);
93
- Object.keys(a.value).forEach((i) => {
94
- a.value[i].recommended = !1, Date.now() - a.value[i].discoveryTime > 5e3 && delete a.value[i];
95
- }), e.forEach((i) => {
96
- a.value[i.deviceId] = i, i.discoveryTime = Date.now();
93
+ Object.keys(a.value).forEach((s) => {
94
+ a.value[s].recommended = !1, Date.now() - a.value[s].discoveryTime > 5e3 && delete a.value[s];
95
+ }), e.forEach((s) => {
96
+ a.value[s.deviceId] = s, s.discoveryTime = Date.now();
97
97
  });
98
- const c = [...Object.values(a.value)].sort((i, _) => _.RSSI - i.RSSI)[0];
98
+ const c = [...Object.values(a.value)].sort((s, _) => _.RSSI - s.RSSI)[0];
99
99
  c && (c.recommended = !0);
100
100
  });
101
101
  }
@@ -103,7 +103,7 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
103
103
  C.next();
104
104
  }
105
105
  function y(o) {
106
- k || (r.loading("正在连接"), k = !0, L.next(), s.connect(new me(o)).pipe(
106
+ k || (r.loading("正在连接"), k = !0, L.next(), i.connect(new fe(o)).pipe(
107
107
  B(() => {
108
108
  f(), S("connect", o), r.success("连接成功"), setTimeout(R, 600);
109
109
  }),
@@ -111,14 +111,14 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
111
111
  throw e.errCode === 10003 ? r.tips("连接超时,请重试") : r.tips(`连接失败:${e.errCode}:${e.errMsg}`), e;
112
112
  }),
113
113
  O(() => k = !1),
114
- m(() => s.connected.pipe(F((e) => !e))),
114
+ m(() => i.connected.pipe(F((e) => !e))),
115
115
  // 监听断开
116
116
  N(L)
117
117
  ).subscribe(() => {
118
118
  S("disconnect", o), r.error("连接断开");
119
119
  }));
120
120
  }
121
- function W(o) {
121
+ function G(o) {
122
122
  V() && (u.value = !0, w.openAdapter().pipe(
123
123
  O(() => {
124
124
  u.value = !1;
@@ -127,24 +127,24 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
127
127
  y(o);
128
128
  }));
129
129
  }
130
- function G() {
130
+ function H() {
131
131
  var o;
132
- (o = s.disconnect()) == null || o.pipe(
133
- we("正在断开")
132
+ (o = i.disconnect()) == null || o.pipe(
133
+ he("正在断开")
134
134
  ).subscribe();
135
135
  }
136
- function H({ detail: o }) {
136
+ function J({ detail: o }) {
137
137
  switch (o.id) {
138
138
  case 1:
139
- G();
139
+ H();
140
140
  break;
141
141
  case 2:
142
- De(Se.confirm("温馨提示", "您确定要关闭设备电源吗?")).pipe(
142
+ Ce(ke.confirm("温馨提示", "您确定要关闭设备电源吗?")).pipe(
143
143
  B(() => r.loading("正在关机")),
144
- m(() => s.shutdown()),
144
+ m(() => i.shutdown()),
145
145
  D(() => E(null)),
146
146
  // 关机后距离信号丢失还有一段时间,这里主动断开连接,改进用户体验
147
- m(() => s.disconnect())
147
+ m(() => i.disconnect())
148
148
  ).subscribe(() => {
149
149
  r.success("设备已关机");
150
150
  });
@@ -154,19 +154,19 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
154
154
  function R() {
155
155
  S("update:show", !1);
156
156
  }
157
- return X(() => v.show, async (o) => {
157
+ return Y(() => v.show, async (o) => {
158
158
  if (o) {
159
159
  if (!M.value)
160
160
  if (v.mac) {
161
- const { platform: e } = await be();
162
- e === "ios" ? x() : W(v.mac);
161
+ const { platform: e } = await ye();
162
+ e === "ios" ? I() : G(v.mac);
163
163
  } else
164
- x();
164
+ I();
165
165
  } else
166
166
  u.value && f();
167
- }), Y(() => {
167
+ }), Z(() => {
168
168
  f();
169
- }), (o, e) => (h(), b("view", Oe, [
169
+ }), (o, e) => (h(), b("view", Te, [
170
170
  n("van-action-sheet", {
171
171
  show: o.show,
172
172
  title: "OPPER",
@@ -174,44 +174,41 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
174
174
  onClose: e[2] || (e[2] = (t) => R())
175
175
  }, [
176
176
  l(M) ? (h(), b(T, { key: 0 }, [
177
- n("view", Le, [
178
- n("view", Me, [
179
- e[7] || (e[7] = n("view", { class: "sun-opper-controller-device-title" }, "设备已连接", -1)),
180
- n("view", Pe, [
181
- Ie(p(l(d).name || "OPPER") + " ", 1),
177
+ n("view", Me, [
178
+ n("view", Pe, [
179
+ e[6] || (e[6] = n("view", { class: "sun-opper-controller-device-title" }, "设备已连接", -1)),
180
+ n("view", Re, [
181
+ $e(p(l(d).name || "OPPER") + " ", 1),
182
182
  n("view", {
183
- class: xe(["sun-opper-controller-device-battery", { "sun-opper-controller-device-battery-active": l(d).charging }])
183
+ class: Ee(["sun-opper-controller-device-battery", { "sun-opper-controller-device-battery-active": l(d).charging }])
184
184
  }, [
185
- e[6] || (e[6] = n("van-icon", {
186
- "class-prefix": "iconfont",
187
- name: "lightning"
188
- }, null, -1)),
189
- ke(n("text", null, p(l(d).volt) + "%", 513), [
190
- [Ce, l(d).volt]
185
+ U(l(be), { name: "flash" }),
186
+ xe(n("text", null, p(l(d).volt) + "%", 513), [
187
+ [Ie, l(d).volt]
191
188
  ])
192
189
  ], 2)
193
190
  ])
194
191
  ]),
195
- n("view", Re, [
196
- n("view", ze, [
197
- e[8] || (e[8] = n("view", null, "设备号", -1)),
192
+ n("view", ze, [
193
+ n("view", Ve, [
194
+ e[7] || (e[7] = n("view", null, "设备号", -1)),
198
195
  n("view", null, p(l(d).id), 1)
199
196
  ]),
200
- n("view", Ve, [
201
- e[9] || (e[9] = n("view", null, "秤台精度", -1)),
197
+ n("view", Ae, [
198
+ e[8] || (e[8] = n("view", null, "秤台精度", -1)),
202
199
  n("view", null, p(l(d).accuracy || 1) + "克", 1)
203
200
  ]),
204
- n("view", Ae, [
205
- e[10] || (e[10] = n("view", null, "固件版本", -1)),
201
+ n("view", je, [
202
+ e[9] || (e[9] = n("view", null, "固件版本", -1)),
206
203
  n("view", null, p(l(d).version), 1)
207
204
  ]),
208
- n("view", je, [
209
- e[11] || (e[11] = n("view", null, "序列号", -1)),
205
+ n("view", Fe, [
206
+ e[10] || (e[10] = n("view", null, "序列号", -1)),
210
207
  n("view", null, p(l(d).serialNumber), 1)
211
208
  ])
212
209
  ])
213
210
  ]),
214
- n("view", Fe, [
211
+ n("view", Ue, [
215
212
  n("van-button", {
216
213
  type: "danger",
217
214
  round: "true",
@@ -220,15 +217,15 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
220
217
  }, " 断开连接 ", 32)
221
218
  ])
222
219
  ], 64)) : (h(), b(T, { key: 1 }, [
223
- Ne(l(he), {
220
+ U(l(ge), {
224
221
  class: "sun-opper-controller-device-list",
225
222
  refresher: !1,
226
223
  data: P.value,
227
224
  loading: u.value,
228
225
  "loading-text": "正在扫描"
229
226
  }, {
230
- default: Be(() => [
231
- (h(!0), b(T, null, Ee(P.value, (t) => (h(), b("van-cell", {
227
+ default: Oe(() => [
228
+ (h(!0), b(T, null, Be(P.value, (t) => (h(), b("van-cell", {
232
229
  key: t.deviceId,
233
230
  title: t.name,
234
231
  label: t.deviceId,
@@ -237,33 +234,33 @@ const l = Z, n = ee, p = te, Ce = ne, ke = oe, xe = ie, Ie = se, T = re, h = le,
237
234
  onTap: (c) => y(t.deviceId)
238
235
  }, [
239
236
  n("text", {
240
- style: $e({ color: t.recommended ? "var(--color-success)" : "inherit" })
237
+ style: Ne({ color: t.recommended ? "var(--color-success)" : "inherit" })
241
238
  }, p(t.RSSI) + "dBm", 5)
242
- ], 40, Ue))), 128))
239
+ ], 40, qe))), 128))
243
240
  ]),
244
241
  _: 1
245
242
  }, 8, ["data", "loading"]),
246
- n("view", qe, [
243
+ n("view", Ke, [
247
244
  n("van-button", {
248
245
  type: "primary",
249
246
  round: "true",
250
247
  block: "true",
251
- onTap: e[1] || (e[1] = (t) => u.value ? f() : x())
248
+ onTap: e[1] || (e[1] = (t) => u.value ? f() : I())
252
249
  }, p(u.value ? "停止扫描" : "扫描 OPPER 设备"), 33)
253
250
  ])
254
251
  ], 64))
255
- ], 40, Te),
252
+ ], 40, Le),
256
253
  n("van-action-sheet", {
257
254
  show: g.value,
258
- actions: K,
255
+ actions: W,
259
256
  "cancel-text": "取消",
260
- onSelect: e[3] || (e[3] = (t) => H(t)),
257
+ onSelect: e[3] || (e[3] = (t) => J(t)),
261
258
  onCancel: e[4] || (e[4] = (t) => g.value = !1),
262
259
  onClose: e[5] || (e[5] = (t) => g.value = !1)
263
- }, null, 40, Ke)
260
+ }, null, 40, We)
264
261
  ]));
265
262
  }
266
263
  });
267
264
  export {
268
- tt as default
265
+ nt as default
269
266
  };