Files
huishou/dist/build/mp-weixin/pages/bluetooth/bluetooth.js
T
2026-07-27 13:37:48 +08:00

2 lines
1.5 KiB
JavaScript

"use strict";var e=(e,n,t)=>new Promise((i,o)=>{var s=e=>{try{r(t.next(e))}catch(n){o(n)}},c=e=>{try{r(t.throw(e))}catch(n){o(n)}},r=e=>e.done?i(e.value):Promise.resolve(e.value).then(s,c);r((t=t.apply(e,n)).next())});const n=require("../../common/vendor.js"),t=require("../../common/assets.js"),i=require("../../stores/bluetooth.js"),o=n.defineComponent({__name:"bluetooth",setup(o){const s=i.useBluetoothStore(),c=()=>{s.isDiscovering?s.stopScan():s.startScan()},r=t=>e(this,null,function*(){s.isConnected&&(yield s.disconnect()),yield s.connect(t),s.isConnected&&(n.index.showToast({title:"连接成功",icon:"success"}),setTimeout(()=>{n.index.navigateBack()},1500))}),d=()=>e(this,null,function*(){yield s.disconnect(),n.index.showToast({title:"已断开连接",icon:"none"})});return(e,i)=>{var o;return n.e({a:n.unref(s).isDiscovering?"/static/icons/remind.png":"/static/icons/search.png",b:n.t(n.unref(s).isDiscovering?"停止搜索":"搜索设备"),c:n.unref(s).isDiscovering?1:"",d:n.o(c),e:n.unref(s).isConnected},n.unref(s).isConnected?{f:n.t(null==(o=n.unref(s).connectedDevice)?void 0:o.name),g:n.o(d)}:{},{h:n.unref(s).deviceList.length>0},n.unref(s).deviceList.length>0?{i:n.f(n.unref(s).deviceList,(e,t,i)=>{return{a:n.t(e.name),b:n.t(e.deviceId),c:n.t((o=e.RSSI,o>=-50?"📶":o>=-70?"📡":"📴")),d:e.deviceId,e:n.o(n=>r(e.deviceId),e.deviceId)};var o})}:{j:t._imports_0$3},{k:t._imports_1$2})}}}),s=n._export_sfc(o,[["__scopeId","data-v-5964b8fb"]]);wx.createPage(s);