[AI Generated]: feat(Comp): 重写用户同步逻辑支持主子用户、移除callWithTimeout、新增用户上限10人及主用户删除保护

This commit is contained in:
17792275749
2026-04-13 13:21:59 +08:00
parent 4e2e8fb899
commit 4fc829a81f
9 changed files with 118 additions and 264 deletions
@@ -1,8 +1,5 @@
const app = getApp();
// 超时时间:15 秒
const SDK_TIMEOUT = 15000;
Component({
data: {
progress: 0,
@@ -27,25 +24,21 @@ Component({
methods: {
initWifi() {
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;
}
this._sdkCancel = app.callWithTimeout(
(done) => activeProtocol.dataFindSurroundDevice(done),
SDK_TIMEOUT,
(res) => {
wx.hideLoading();
this.setData({ wifiList: Array.isArray(res) ? res : [] });
},
() => {
wx.hideLoading();
wx.showToast({ title: "获取Wi-Fi列表超时,请重试", icon: "none" });
activeProtocol.dataFindSurroundDevice((res) => {
wx.hideLoading();
if (!Array.isArray(res)) {
// 获取失败,自动重试
this.initWifi();
return;
}
);
this.setData({ wifiList: res });
});
},
// 最小化后重连,重置所有状态并重新获取 WiFi 列表
@@ -26,7 +26,7 @@
<view>
<image src="/images/configureDevice/null.png" />
</view>
<view>获取WIFI失败</view>
<view>暂无WIFI数据,点击重新获取</view>
</view>
</block>
</view>