fix: 修复蓝牙异常和OTA升级的返回逻辑问题
1. 蓝牙操作失败时立即隐藏加载弹窗避免卡住 2. 首页断开蓝牙时延迟刷新UI并正确刷新主页 3. OTA升级期间拦截返回操作,升级完成后恢复
This commit is contained in:
parent
d41c3384df
commit
40a3a841a9
@ -2505,6 +2505,7 @@ namespace Kill.Bluetooth
|
||||
if (BluetoothManager.Instance == null)
|
||||
{
|
||||
LogError("BluetoothManager.Instance 为 null");
|
||||
LoadingUI.Hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2513,6 +2514,7 @@ namespace Kill.Bluetooth
|
||||
{
|
||||
Log("蓝牙未初始化,尝试自动初始化...");
|
||||
BluetoothManager.Instance.Initialize();
|
||||
LoadingUI.Hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2521,6 +2523,7 @@ namespace Kill.Bluetooth
|
||||
{
|
||||
LogError("蓝牙未连接");
|
||||
ToastUI.Show("100081"); // "请先连接蓝牙设备"
|
||||
LoadingUI.Hide(); // 未连接时立即隐藏Loading,避免一直转圈
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -172,11 +172,17 @@ namespace Kill.UI.Pages
|
||||
UpdateLoadingUI.Instance.Show();
|
||||
uint firmwareVersion = ParseFirmwareVersion(otaData.version);
|
||||
OTAManager.Instance.OnTransferProgress += OnOTATransferProgress;
|
||||
// OTA 传输期间清空返回事件,防止用户触发返回中断升级;传输结束恢复
|
||||
var otaBackAction = UIManager.Instance.GetBackAction();
|
||||
UIManager.Instance.ClearBackAction();
|
||||
StartCoroutine(OTAManager.Instance.PerformFullUpgrade(_selectedFirmwareData, firmwareVersion, (success) =>
|
||||
{
|
||||
Loom.QueueOnMainThread(() =>
|
||||
{
|
||||
isUpdating = false;
|
||||
// 恢复返回事件
|
||||
if (otaBackAction != null)
|
||||
UIManager.Instance.RegisterBackAction(otaBackAction);
|
||||
if (success)
|
||||
{
|
||||
ToastUI.Show("100226");
|
||||
|
||||
@ -330,12 +330,16 @@ namespace Kill.UI.Pages
|
||||
isQueryingStatus = false;
|
||||
statusQueryQueue?.Clear();
|
||||
UIManager.Instance?.ClearBackAction();
|
||||
// OpenPage 已移至 BluetoothManager.OnSelfDisconnected(全局监听 + 延迟)
|
||||
// 刷新首页设备连接状态UI(延迟到主循环执行,与连接成功时保持一致)
|
||||
pendingUIUpdates.Add(() =>
|
||||
{
|
||||
deviceState?.UpdateDeviceState(hasBluetooth, hasWifi);
|
||||
});
|
||||
if(bluetoothDeviceInfoCoroutine!=null)
|
||||
{
|
||||
StopCoroutine(bluetoothDeviceInfoCoroutine);
|
||||
}
|
||||
|
||||
UIManager.Instance?.OpenMainPage(UIManager.PageName.homePage);
|
||||
}
|
||||
|
||||
private void OnBluetoothError(string error)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user