Compare commits

..
2 Commits
Author SHA1 Message Date
17792275749andClaude Opus 4.7 c4bde77fd1 style(userManagement): 设备图标加最小宽度
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-08-25 21:11:48 +08:00
17792275749andClaude Opus 4.7 f3f4d56ceb fix(equipment): 回前台自动重连后同步设备连接状态
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-08-25 21:11:42 +08:00
2 changed files with 18 additions and 1 deletions
+17 -1
View File
@@ -53,6 +53,7 @@ interface DeviceItem {
let unsubDevicesList: (() => void) | null = null
let unsubConnect: (() => void) | null = null
let unsubDisconnected: (() => void) | null = null
let unsubDeviceConnect: (() => void) | null = null
let scanTimer: number | null = null
Page({
@@ -68,18 +69,23 @@ Page({
this.setData({ operationsEngineer: getApp<IAppOption>().globalData.operationsEngineer ?? false })
this.loadDevices()
this._subscribeDisconnected()
this._subscribeDeviceConnect()
},
onHide() {
leFuService.stopScan()
unsubDisconnected?.()
unsubDisconnected = null
unsubDeviceConnect?.()
unsubDeviceConnect = null
},
onUnload() {
leFuService.stopScan()
unsubDisconnected?.()
unsubDisconnected = null
unsubDeviceConnect?.()
unsubDeviceConnect = null
unsubDevicesList?.()
unsubDevicesList = null
unsubConnect?.()
@@ -97,6 +103,17 @@ Page({
})
},
/** 订阅连接成功事件:回前台自动重连等场景下,同步页面状态为已连接 */
_subscribeDeviceConnect() {
unsubDeviceConnect?.()
unsubDeviceConnect = leFuService.onDeviceConnect(() => {
const deviceId = leFuService.lastRawDevice?.deviceId ?? ''
if (deviceId) {
this._updateStatus(deviceId, true)
}
})
},
/** 拉取体重设备列表 */
async loadDevices() {
const raw = wx.getStorageSync('userInfo') as UserInfo | null
@@ -203,7 +220,6 @@ Page({
unsubConnect = null
wx.hideLoading()
wx.setStorageSync('connectDeviceInfo', matched.raw)
this._updateStatus(targetDeviceId, true)
})
})
leFuService.startScan()
@@ -22,6 +22,7 @@
.device-icon {
width: 88rpx;
min-width: 88rpx;
height: 88rpx;
overflow: hidden;
margin-right: 20rpx;