fix: 修复蓝牙异常和OTA升级的返回逻辑问题

1. 蓝牙操作失败时立即隐藏加载弹窗避免卡住
2. 首页断开蓝牙时延迟刷新UI并正确刷新主页
3. OTA升级期间拦截返回操作,升级完成后恢复
This commit is contained in:
“虞渠成” 2026-08-14 11:24:48 +08:00
parent d41c3384df
commit 40a3a841a9
3 changed files with 15 additions and 2 deletions

View File

@ -2505,6 +2505,7 @@ namespace Kill.Bluetooth
if (BluetoothManager.Instance == null) if (BluetoothManager.Instance == null)
{ {
LogError("BluetoothManager.Instance 为 null"); LogError("BluetoothManager.Instance 为 null");
LoadingUI.Hide();
return false; return false;
} }
@ -2513,6 +2514,7 @@ namespace Kill.Bluetooth
{ {
Log("蓝牙未初始化,尝试自动初始化..."); Log("蓝牙未初始化,尝试自动初始化...");
BluetoothManager.Instance.Initialize(); BluetoothManager.Instance.Initialize();
LoadingUI.Hide();
return false; return false;
} }
@ -2521,6 +2523,7 @@ namespace Kill.Bluetooth
{ {
LogError("蓝牙未连接"); LogError("蓝牙未连接");
ToastUI.Show("100081"); // "请先连接蓝牙设备" ToastUI.Show("100081"); // "请先连接蓝牙设备"
LoadingUI.Hide(); // 未连接时立即隐藏Loading避免一直转圈
return false; return false;
} }

View File

@ -172,11 +172,17 @@ namespace Kill.UI.Pages
UpdateLoadingUI.Instance.Show(); UpdateLoadingUI.Instance.Show();
uint firmwareVersion = ParseFirmwareVersion(otaData.version); uint firmwareVersion = ParseFirmwareVersion(otaData.version);
OTAManager.Instance.OnTransferProgress += OnOTATransferProgress; OTAManager.Instance.OnTransferProgress += OnOTATransferProgress;
// OTA 传输期间清空返回事件,防止用户触发返回中断升级;传输结束恢复
var otaBackAction = UIManager.Instance.GetBackAction();
UIManager.Instance.ClearBackAction();
StartCoroutine(OTAManager.Instance.PerformFullUpgrade(_selectedFirmwareData, firmwareVersion, (success) => StartCoroutine(OTAManager.Instance.PerformFullUpgrade(_selectedFirmwareData, firmwareVersion, (success) =>
{ {
Loom.QueueOnMainThread(() => Loom.QueueOnMainThread(() =>
{ {
isUpdating = false; isUpdating = false;
// 恢复返回事件
if (otaBackAction != null)
UIManager.Instance.RegisterBackAction(otaBackAction);
if (success) if (success)
{ {
ToastUI.Show("100226"); ToastUI.Show("100226");

View File

@ -330,12 +330,16 @@ namespace Kill.UI.Pages
isQueryingStatus = false; isQueryingStatus = false;
statusQueryQueue?.Clear(); statusQueryQueue?.Clear();
UIManager.Instance?.ClearBackAction(); UIManager.Instance?.ClearBackAction();
// OpenPage 已移至 BluetoothManager.OnSelfDisconnected全局监听 + 延迟) // 刷新首页设备连接状态UI延迟到主循环执行与连接成功时保持一致
pendingUIUpdates.Add(() =>
{
deviceState?.UpdateDeviceState(hasBluetooth, hasWifi);
});
if(bluetoothDeviceInfoCoroutine!=null) if(bluetoothDeviceInfoCoroutine!=null)
{ {
StopCoroutine(bluetoothDeviceInfoCoroutine); StopCoroutine(bluetoothDeviceInfoCoroutine);
} }
UIManager.Instance?.OpenMainPage(UIManager.PageName.homePage);
} }
private void OnBluetoothError(string error) private void OnBluetoothError(string error)