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