fix: 修复蓝牙连接误报与 WiFi 列表获取问题,完善一键添加本人
- connectedDevice 忽略 connect 过程中的 UNAVAILABLE 抖动,避免误报蓝牙关闭 - getWifiList 加 settled 保护,onStartSearch 加防重入 - userManagement 一键添加本人(仅加后台、不下发设备) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
b4d3a034ba
commit
dbb2ab8423
@@ -4,6 +4,8 @@ import { leFuService } from '../../lefu/index'
|
||||
let unsubDisconnected: (() => void) | null = null
|
||||
let unsubDeviceConnect: (() => void) | null = null
|
||||
let retryTimer: number | null = null
|
||||
/** 获取 WiFi 列表防重入标记 */
|
||||
let searching = false
|
||||
|
||||
/** 渲染用的 WiFi 项(在 SSID 基础上追加连接状态) */
|
||||
interface WifiItem {
|
||||
@@ -74,10 +76,12 @@ Page({
|
||||
|
||||
/** 通过设备协议获取周围 WiFi 列表 */
|
||||
async onStartSearch() {
|
||||
if (searching) return
|
||||
if (!this._ensureConnected()) {
|
||||
this.setData({ status: 'idle', wifiList: [] })
|
||||
return
|
||||
}
|
||||
searching = true
|
||||
this.setData({ status: 'searching', wifiList: [] })
|
||||
wx.showLoading({ title: '正在获取 WiFi 列表...', mask: true })
|
||||
try {
|
||||
@@ -95,6 +99,8 @@ Page({
|
||||
wx.hideLoading()
|
||||
this.setData({ status: 'empty', wifiList: [] })
|
||||
wx.showToast({ title: '获取 WiFi 列表失败', icon: 'none' })
|
||||
} finally {
|
||||
searching = false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -167,6 +173,6 @@ Page({
|
||||
onConfirm() {
|
||||
if (!this.data.hasConnected) return
|
||||
if (!this._ensureConnected()) return
|
||||
wx.navigateTo({ url: '/pages/equipment/equipment' })
|
||||
wx.reLaunch({ url: '/pages/equipment/equipment' })
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user