"use strict"; const common_vendor = require("../../common/vendor.js"); const stores_bluetooth = require("../../stores/bluetooth.js"); const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "bluetooth", setup(__props) { const bluetoothStore = stores_bluetooth.useBluetoothStore(); const toggleScan = () => { if (bluetoothStore.isDiscovering) { bluetoothStore.stopScan(); } else { bluetoothStore.startScan(); } }; const connect = async (deviceId) => { if (bluetoothStore.isConnected) { await bluetoothStore.disconnect(); } await bluetoothStore.connect(deviceId); if (bluetoothStore.isConnected) { common_vendor.index.showToast({ title: "连接成功", icon: "success" }); setTimeout(() => { common_vendor.index.navigateBack(); }, 1500); } }; const disconnect = async () => { await bluetoothStore.disconnect(); common_vendor.index.showToast({ title: "已断开连接", icon: "none" }); }; const getSignalStrength = (rssi) => { if (rssi >= -50) return "📶"; if (rssi >= -70) return "📡"; return "📴"; }; return (_ctx, _cache) => { var _a; return common_vendor.e({ a: common_vendor.t(common_vendor.unref(bluetoothStore).isDiscovering ? "⏹️" : "🔍"), b: common_vendor.t(common_vendor.unref(bluetoothStore).isDiscovering ? "停止搜索" : "搜索设备"), c: common_vendor.unref(bluetoothStore).isDiscovering ? 1 : "", d: common_vendor.o(toggleScan), e: common_vendor.unref(bluetoothStore).isConnected }, common_vendor.unref(bluetoothStore).isConnected ? { f: common_vendor.t((_a = common_vendor.unref(bluetoothStore).connectedDevice) == null ? void 0 : _a.name), g: common_vendor.o(disconnect) } : {}, { h: common_vendor.unref(bluetoothStore).deviceList.length > 0 }, common_vendor.unref(bluetoothStore).deviceList.length > 0 ? { i: common_vendor.f(common_vendor.unref(bluetoothStore).deviceList, (device, k0, i0) => { return { a: common_vendor.t(device.name), b: common_vendor.t(device.deviceId), c: common_vendor.t(getSignalStrength(device.RSSI)), d: device.deviceId, e: common_vendor.o(($event) => connect(device.deviceId), device.deviceId) }; }) } : {}); }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b0f86abb"]]); wx.createPage(MiniProgramPage);