From 148e197ea1b5a13fcc40637281f231ee9717916e Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 25 Dec 2025 22:12:12 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile-app):=20=E5=8D=87=E7=BA=A7=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=98=BE=E7=A4=BA=E6=97=B6=E8=B7=B3=E8=BF=87=E5=90=88?= =?UTF-8?q?=E5=90=8C/KYC=E5=90=8E=E5=8F=B0=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - UpdateService 添加 isShowingUpdateDialog 状态 - home_shell_page 在升级、合同签署、KYC页面均跳过后台弹窗 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../lib/core/updater/update_service.dart | 25 +++++++++++++------ .../presentation/pages/home_shell_page.dart | 23 +++++++++++------ 2 files changed, 32 insertions(+), 16 deletions(-) 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; }