[AI Generated]: fix(Comp): 新增 SDK 超时取消机制,组件销毁时清除定时器防止残留提示

This commit is contained in:
17792275749
2026-04-09 10:53:53 +08:00
parent 65acceba2a
commit 8cb7a11fbe
4 changed files with 18 additions and 11 deletions
@@ -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) => {