From 1a027b6ec1c3cf96e7c5113e0d08049e88968bef Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Wed, 8 Oct 2025 10:16:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=93=9D=E7=89=99=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/blueToothTest/item2.vue | 880 +++++++++++++++++++++++++ app/components/blufi/crypto/aes.js | 17 +- 2 files changed, 893 insertions(+), 4 deletions(-) diff --git a/app/components/blueToothTest/item2.vue b/app/components/blueToothTest/item2.vue index 27324a8..ad68919 100644 --- a/app/components/blueToothTest/item2.vue +++ b/app/components/blueToothTest/item2.vue @@ -1,11 +1,891 @@ + + + + + + Web端蓝牙设备控制 + + + 基于Blufi系统的蓝牙设备扫描、连接和控制 + + + + + + + + 设备扫描和控制 + + + + + + + + Web Bluetooth API: {{ bluetoothState.isSupported ? '支持' : '不支持' }} + + + + + + + + {{ bluetoothState.isScanning ? '扫描中...' : '开始扫描设备' }} + + + + 停止扫描 + + + + + + 发现的设备 + + + + {{ device.name || '未知设备' }} + {{ device.deviceId }} + + + 连接 + + + + 暂无发现的设备 + + + + + + + + 初始化设备 + + + + 断开连接 + + + + + + + + 设备信息 + + + + + 设备名称: + {{ bluetoothState.deviceInfo.name || '未连接' }} + + + + 设备ID: + {{ bluetoothState.deviceInfo.id || '未连接' }} + + + + 连接状态: + + + + {{ bluetoothState.isConnected ? '已连接' : '未连接' }} + + + + + + 电池电量: + {{ bluetoothState.deviceInfo.batteryLevel }}% + + + + 固件版本: + {{ bluetoothState.deviceInfo.firmwareVersion || '未知' }} + + + + + + + + + + + 基础控制 + + + + + + LED控制: + + {{ controlCommands.ledOn ? '关闭LED' : '开启LED' }} + + + + + + + 电机速度: {{ controlCommands.motorSpeed }}% + + + + + + + + 温度设置: {{ controlCommands.temperature }}°C + + + + + + + + 湿度设置: {{ controlCommands.humidity }}% + + + + + + + + + + WiFi配置和自定义数据 + + + + + + WiFi网络名称 (SSID) + + + + + WiFi密码 + + + + + 发送WiFi配置 + + + + + 自定义数据命令 + + + + + 发送自定义数据 + + + + + + + + + + 操作日志 + + + 清除日志 + + + + + + 暂无日志记录 + + + + {{ log }} + + + + + + \ No newline at end of file diff --git a/app/components/blufi/crypto/aes.js b/app/components/blufi/crypto/aes.js index 03d90a3..c30a6ce 100644 --- a/app/components/blufi/crypto/aes.js +++ b/app/components/blufi/crypto/aes.js @@ -1157,9 +1157,18 @@ } else if (typeof define === 'function' && define.amd) { define(aesjs) } else { - if (root.aesjs) { - aesjs._aesjs = root.aesjs + // 修复Web环境中的this上下文问题 + const globalThis = (function() { + if (typeof globalThis !== 'undefined') return globalThis + if (typeof self !== 'undefined') return self + if (typeof window !== 'undefined') return window + if (typeof global !== 'undefined') return global + return {} + })() + + if (globalThis.aesjs) { + aesjs._aesjs = globalThis.aesjs } - root.aesjs = aesjs + globalThis.aesjs = aesjs } -})(this) +})(typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {})
+ 基于Blufi系统的蓝牙设备扫描、连接和控制 +
{{ device.name || '未知设备' }}
{{ device.deviceId }}