diff --git a/frontend/mobile-app/lib/core/updater/update_service.dart b/frontend/mobile-app/lib/core/updater/update_service.dart index 67e0f3f0..09df23e2 100644 --- a/frontend/mobile-app/lib/core/updater/update_service.dart +++ b/frontend/mobile-app/lib/core/updater/update_service.dart @@ -19,10 +19,14 @@ class UpdateService { late UpdateConfig _config; SelfHostedUpdater? _selfHostedUpdater; bool _isInitialized = false; + bool _isShowingUpdateDialog = false; /// 是否已初始化 bool get isInitialized => _isInitialized; + /// 是否正在显示升级弹窗 + bool get isShowingUpdateDialog => _isShowingUpdateDialog; + /// 当前配置 UpdateConfig get config => _config; @@ -64,13 +68,18 @@ class UpdateService { return; } - switch (_config.channel) { - case UpdateChannel.googlePlay: - await _checkGooglePlayUpdate(context); - break; - case UpdateChannel.selfHosted: - await _selfHostedUpdater!.checkAndPromptUpdate(context); - break; + _isShowingUpdateDialog = true; + try { + switch (_config.channel) { + case UpdateChannel.googlePlay: + await _checkGooglePlayUpdate(context); + break; + case UpdateChannel.selfHosted: + await _selfHostedUpdater!.checkAndPromptUpdate(context); + break; + } + } finally { + _isShowingUpdateDialog = false; } } @@ -99,7 +108,7 @@ class UpdateService { if (!context.mounted) return; - showDialog( + await showDialog( context: context, builder: (context) => AlertDialog( title: Text( diff --git a/frontend/mobile-app/lib/features/home/presentation/pages/home_shell_page.dart b/frontend/mobile-app/lib/features/home/presentation/pages/home_shell_page.dart index d2a4fbb8..ab4d5c88 100644 --- a/frontend/mobile-app/lib/features/home/presentation/pages/home_shell_page.dart +++ b/frontend/mobile-app/lib/features/home/presentation/pages/home_shell_page.dart @@ -6,6 +6,7 @@ import 'package:go_router/go_router.dart'; import '../../../../core/theme/app_colors.dart'; import '../../../../core/di/injection_container.dart'; import '../../../../core/services/contract_check_service.dart'; +import '../../../../core/updater/update_service.dart'; import '../../../../routes/route_paths.dart'; import '../../../../bootstrap.dart'; import '../widgets/bottom_nav_bar.dart'; @@ -100,8 +101,14 @@ class _HomeShellPageState extends ConsumerState }); } - /// 检查当前是否在合同签署或KYC相关页面 - bool _isOnContractOrKycPage() { + /// 检查当前是否在合同签署或KYC相关页面,或者正在显示升级弹窗 + bool _shouldSkipContractCheck() { + // 1. 检查是否正在显示升级弹窗 + if (UpdateService().isShowingUpdateDialog) { + return true; + } + + // 2. 检查是否在合同/KYC页面 try { final location = GoRouterState.of(context).uri.path; // 合同签署相关页面 @@ -118,9 +125,9 @@ class _HomeShellPageState extends ConsumerState Future _performBackgroundContractCheck() async { if (!mounted || _isShowingDialog) return; - // 如果用户在合同签署或KYC页面,跳过检查 - if (_isOnContractOrKycPage()) { - debugPrint('[HomeShellPage] 用户在合同/KYC页面,跳过后台检查'); + // 如果用户在合同签署、KYC页面,或正在升级,跳过检查 + if (_shouldSkipContractCheck()) { + debugPrint('[HomeShellPage] 用户在合同/KYC/升级页面,跳过后台检查'); return; } @@ -132,9 +139,9 @@ class _HomeShellPageState extends ConsumerState if (!mounted || _isShowingDialog) return; - // 再次检查,防止在请求期间用户进入了相关页面 - if (_isOnContractOrKycPage()) { - debugPrint('[HomeShellPage] 用户已进入合同/KYC页面,跳过弹窗'); + // 再次检查,防止在请求期间用户进入了相关页面或开始升级 + if (_shouldSkipContractCheck()) { + debugPrint('[HomeShellPage] 用户已进入合同/KYC/升级页面,跳过弹窗'); return; }