fix(mobile-app): 升级弹窗显示时跳过合同/KYC后台检查
- UpdateService 添加 isShowingUpdateDialog 状态 - home_shell_page 在升级、合同签署、KYC页面均跳过后台弹窗 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5ee12be00f
commit
148e197ea1
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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<HomeShellPage>
|
|||
});
|
||||
}
|
||||
|
||||
/// 检查当前是否在合同签署或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<HomeShellPage>
|
|||
Future<void> _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<HomeShellPage>
|
|||
|
||||
if (!mounted || _isShowingDialog) return;
|
||||
|
||||
// 再次检查,防止在请求期间用户进入了相关页面
|
||||
if (_isOnContractOrKycPage()) {
|
||||
debugPrint('[HomeShellPage] 用户已进入合同/KYC页面,跳过弹窗');
|
||||
// 再次检查,防止在请求期间用户进入了相关页面或开始升级
|
||||
if (_shouldSkipContractCheck()) {
|
||||
debugPrint('[HomeShellPage] 用户已进入合同/KYC/升级页面,跳过弹窗');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue