fix: BLE connection leak on page unload and retry timer cleanup
- onUnload disconnects BLE if not in 'done' state (prevents connection leak) - onUnload clears retry timer to prevent setData on dead page - Store retry setTimeout ref for proper cleanup
这个提交包含在:
@@ -34,8 +34,15 @@ Page({
|
||||
|
||||
onUnload: function () {
|
||||
clearTimeout(this._scanTimer)
|
||||
clearTimeout(this._retryTimer)
|
||||
ble.stopScan()
|
||||
if (this._onBindResult) ble.off('bind_result', this._onBindResult)
|
||||
if (this._onBindResult) {
|
||||
ble.off('bind_result', this._onBindResult)
|
||||
this._onBindResult = null
|
||||
}
|
||||
if (this.data.state !== 'done') {
|
||||
ble.disconnect()
|
||||
}
|
||||
},
|
||||
|
||||
startBleConnect: function () {
|
||||
@@ -98,7 +105,7 @@ Page({
|
||||
self._onBindResult = null
|
||||
}
|
||||
ble.disconnect()
|
||||
setTimeout(function () {
|
||||
self._retryTimer = setTimeout(function () {
|
||||
self.startBleConnect()
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
在新工单中引用
屏蔽一个用户