[AI Generated]: fix(Comp): 新增 SDK 超时取消机制,组件销毁时清除定时器防止残留提示
This commit is contained in:
@@ -53,10 +53,10 @@ Component({
|
||||
this.fetchUserList();
|
||||
},
|
||||
detached() {
|
||||
// 4. 在组件销毁时取消监听,防止内存泄漏
|
||||
if (this._connectStateWatcher) {
|
||||
app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
|
||||
}
|
||||
if (this._sdkCancel) { this._sdkCancel(); this._sdkCancel = null; }
|
||||
}
|
||||
},
|
||||
|
||||
@@ -190,7 +190,7 @@ Component({
|
||||
|
||||
// 获取设备端已有用户,与用户列表做双向同步
|
||||
wx.showLoading({ title: "正在同步用户信息...", mask: true });
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataFetchUserID(done),
|
||||
SDK_TIMEOUT,
|
||||
(deviceUserIds) => {
|
||||
@@ -243,7 +243,7 @@ Component({
|
||||
}
|
||||
wx.showLoading({ title: "正在下发第" + (syncIndex + 1) + "/" + needSyncList.length + "个用户...", mask: true });
|
||||
let user = needSyncList[syncIndex];
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataSyncUserInfo({
|
||||
userID: user.userId,
|
||||
userName: user.realname,
|
||||
@@ -290,7 +290,7 @@ Component({
|
||||
}
|
||||
wx.showLoading({ title: "正在删除第" + (delIndex + 1) + "/" + needDeleteList.length + "个多余用户...", mask: true });
|
||||
let item = needDeleteList[delIndex];
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataDeleteUser({
|
||||
userID: item.userID,
|
||||
memberID: ""
|
||||
@@ -330,7 +330,7 @@ Component({
|
||||
*/
|
||||
_checkWifiAndNext() {
|
||||
wx.showLoading({ title: "正在检测配网状态...", mask: true });
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.codeFetchWifiConfig(done),
|
||||
SDK_TIMEOUT,
|
||||
(res) => {
|
||||
|
||||
@@ -20,6 +20,7 @@ Component({
|
||||
},
|
||||
detached() {
|
||||
console.log('configureDevice3 detached');
|
||||
if (this._sdkCancel) { this._sdkCancel(); this._sdkCancel = null; }
|
||||
}
|
||||
},
|
||||
|
||||
@@ -34,7 +35,7 @@ Component({
|
||||
wx.showToast({ title: '设备未连接,请重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => activeProtocol.dataFindSurroundDevice(done),
|
||||
SDK_TIMEOUT,
|
||||
(res) => {
|
||||
@@ -83,7 +84,7 @@ Component({
|
||||
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
@@ -101,7 +102,7 @@ Component({
|
||||
);
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
|
||||
@@ -26,7 +26,7 @@ Component({
|
||||
this.setNerwork();
|
||||
},
|
||||
detached() {
|
||||
|
||||
if (this._sdkCancel) { this._sdkCancel(); this._sdkCancel = null; }
|
||||
}
|
||||
},
|
||||
|
||||
@@ -37,7 +37,7 @@ Component({
|
||||
let password = this.properties.password;
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: ssid,
|
||||
@@ -57,7 +57,7 @@ Component({
|
||||
);
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
app.callWithTimeout(
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: ssid,
|
||||
|
||||
Reference in New Issue
Block a user