fix(lefu): 完善蓝牙连接状态处理,修复断开后 UI 不同步问题

- connectState 回调增加 UNAVAILABLE 清理和 READY 自动重连
- disconnect() 增加 _intentionalConnect 标记避免误重连
- deviceWillDisconnect 增加 _activeProtocol 防重入判断
- connectedDevice/equipment/connectedWifi 增加断开状态响应
- connectedWifi 设备断开后自动退出配网页

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-07-21 09:43:49 +08:00
co-authored by Claude Sonnet 4.6
parent 15e089f5e3
commit 439f560218
7 changed files with 60 additions and 12 deletions
@@ -28,6 +28,11 @@ Page({
onShow() {
console.log(TAG, 'onShow')
// 回到页面时同步实际连接状态,避免回调被其他页面覆盖导致状态不同步
if (!lefuService.isConnected) {
const list = this.data.deviceList.map(item => ({ ...item, connected: false }))
this.setData({ deviceList: list })
}
},
onHide() {
@@ -169,6 +174,10 @@ Page({
this.setData({ _autoConnectTried: true })
this._autoConnectByIndex(matchedIndex)
})
lefuService.onDisconnected(() => {
const list = this.data.deviceList.map(item => ({ ...item, connected: false }))
this.setData({ deviceList: list })
})
lefuService.startScan()
console.log(TAG, 'lefuService.startScan() 已调用')
},