[AI Generated]: fix(*): 修复蓝牙连接全链路问题,包含 bus 重复订阅、activeProtocol 空指针、stop 竞速、重连计数器跨页面共享、OTA 超时保护、硬超时改事件驱动、保活定时器泄漏及回调错误处理
This commit is contained in:
@@ -14,31 +14,28 @@ Component({
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.initWifi();
|
||||
// WiFi 列表获取由父页面在 activeProtocol 就绪后显式调用,此处不自动触发
|
||||
},
|
||||
detached() {
|
||||
// 在组件实例被从页面节点树移除时执行
|
||||
console.log('MyComponent detached!');
|
||||
console.log('configureDevice3 detached');
|
||||
}
|
||||
},
|
||||
|
||||
// 组件的方法
|
||||
methods: {
|
||||
initWifi() {
|
||||
wx.showLoading({
|
||||
title: "正在获取Wi-Fi列表...",
|
||||
mask: true
|
||||
wx.showLoading({ title: "正在获取Wi-Fi列表...", mask: true });
|
||||
// activeProtocol 由父页面在 deviceConnect 回调中赋值,此处直接使用
|
||||
const activeProtocol = app.globalData.ppScale.activeProtocol;
|
||||
if (!activeProtocol) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '设备未连接,请重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
activeProtocol.dataFindSurroundDevice((res) => {
|
||||
wx.hideLoading();
|
||||
this.setData({ wifiList: res });
|
||||
});
|
||||
// 重新获取协议实例,避免用户同步操作后旧引用失效
|
||||
setTimeout(() => {
|
||||
app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol();
|
||||
app.globalData.ppScale.activeProtocol.dataFindSurroundDevice((res) => {
|
||||
wx.hideLoading();
|
||||
this.setData({
|
||||
wifiList: res
|
||||
})
|
||||
})
|
||||
}, 1500);
|
||||
},
|
||||
|
||||
// 最小化后重连,重置所有状态并重新获取 WiFi 列表
|
||||
|
||||
Reference in New Issue
Block a user