更新ios蓝牙开关判定
This commit is contained in:
@@ -93,20 +93,53 @@ class _HomeDeviceStausWidgetState extends State<HomeDeviceStausWidget> {
|
||||
onTap: () async {
|
||||
try {
|
||||
var device = widget.deviceStatus;
|
||||
|
||||
WebviewTestController webviewTestController = Get.find();
|
||||
|
||||
webviewTestController.web.jsbridge?.dart.switchLanguage(
|
||||
mhLanguageController
|
||||
.selectLanguage.value!.language_code);
|
||||
|
||||
await checkBlueToothPermissin();
|
||||
|
||||
webviewTestController.web.jsbridge?.dart
|
||||
.pageActive(false);
|
||||
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
webviewTestController.web.jsbridge?.dart
|
||||
.appToHtmlDevice(device);
|
||||
|
||||
MainPageBBottomChange.jumpTo(2);
|
||||
|
||||
// 🔹 重试调用 appToHtmlDevice
|
||||
int attempt = 0;
|
||||
const int maxAttempts = 10;
|
||||
bool success = false;
|
||||
|
||||
while (attempt < maxAttempts && !success) {
|
||||
try {
|
||||
bool? flag = await webviewTestController
|
||||
.web.jsbridge?.dart
|
||||
.appToHtmlDevice(device);
|
||||
|
||||
if (flag == true) {
|
||||
success = true; // 成功,跳出循环
|
||||
} else {
|
||||
ef.log(
|
||||
"appToHtmlDevice 返回 false,第 ${attempt + 1} 次重试");
|
||||
}
|
||||
} catch (e) {
|
||||
ef.log("appToHtmlDevice 异常,第 ${attempt + 1} 次重试: $e");
|
||||
}
|
||||
|
||||
attempt++;
|
||||
if (!success) {
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
ef.log("appToHtmlDevice 超过最大重试次数 $maxAttempts,调用失败");
|
||||
}
|
||||
} catch (e) {
|
||||
DailyLogUtils.writeError("发生异常: $e");
|
||||
DailyLogUtils.writeError("进入控制页发生异常: $e");
|
||||
}
|
||||
},
|
||||
colors:
|
||||
|
||||
Reference in New Issue
Block a user