|
|
|
@ -482,8 +482,12 @@ class SettingsController extends GetxController { |
|
|
|
if (isCheckingUpdate) return; |
|
|
|
isCheckingUpdate = true; |
|
|
|
|
|
|
|
// 用于跟踪我们的对话框 |
|
|
|
bool dialogShown = false; |
|
|
|
|
|
|
|
try { |
|
|
|
// 显示加载提示 |
|
|
|
dialogShown = true; |
|
|
|
Get.dialog( |
|
|
|
const Center( |
|
|
|
child: CircularProgressIndicator(), |
|
|
|
@ -494,8 +498,12 @@ class SettingsController extends GetxController { |
|
|
|
final versionService = VersionUpdateService.to; |
|
|
|
final updateInfo = await versionService.checkForUpdate(); |
|
|
|
|
|
|
|
// 关闭加载提示 |
|
|
|
Get.back(); |
|
|
|
// 关闭加载提示 - 使用精确的关闭方式 |
|
|
|
if (dialogShown) { |
|
|
|
dialogShown = false; |
|
|
|
// 直接关闭最顶层的对话框,不依赖状态判断 |
|
|
|
Navigator.of(Get.overlayContext!).pop(); |
|
|
|
} |
|
|
|
|
|
|
|
if (updateInfo.hasUpdate) { |
|
|
|
// 显示更新对话框 |
|
|
|
@ -508,21 +516,30 @@ class SettingsController extends GetxController { |
|
|
|
.tr //当前已是最新版本 |
|
|
|
.replaceAll('{version}', updateInfo.currentVersion), |
|
|
|
snackPosition: SnackPosition.TOP, |
|
|
|
backgroundColor: Colors.green.withOpacity(0.8), |
|
|
|
backgroundColor: Colors.green.withValues(alpha: 0.8), |
|
|
|
colorText: Colors.white, |
|
|
|
); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
// 关闭加载提示 |
|
|
|
if (Get.isDialogOpen == true) { |
|
|
|
Get.back(closeOverlays: true); |
|
|
|
// 关闭加载提示 - 异常情况下的可靠关闭 |
|
|
|
if (dialogShown) { |
|
|
|
dialogShown = false; |
|
|
|
try { |
|
|
|
// 尝试直接关闭 |
|
|
|
Navigator.of(Get.overlayContext!).pop(); |
|
|
|
} catch (popError) { |
|
|
|
// 如果直接关闭失败,使用备用方案 |
|
|
|
if (Get.isDialogOpen == true) { |
|
|
|
Get.back(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Get.snackbar( |
|
|
|
'error'.tr, |
|
|
|
'networkErrorRetry'.tr, // 网络错误,请稍后重试 |
|
|
|
snackPosition: SnackPosition.TOP, |
|
|
|
backgroundColor: Colors.red.withOpacity(0.8), |
|
|
|
backgroundColor: Colors.red.withValues(alpha: 0.8), |
|
|
|
colorText: Colors.white, |
|
|
|
); |
|
|
|
} finally { |
|
|
|
|