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