fix(mobile-app): 使用 appRouterProvider 获取全局路由状态
改用 ref.read(appRouterProvider) 替代 GoRouter.of(context), 确保能正确获取到当前的全局路由路径。 🤖 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
ce75e68d5e
commit
b40cd40eae
|
|
@ -8,6 +8,7 @@ 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 '../../../../routes/app_router.dart';
|
||||
import '../../../../bootstrap.dart';
|
||||
import '../widgets/bottom_nav_bar.dart';
|
||||
|
||||
|
|
@ -109,13 +110,11 @@ class _HomeShellPageState extends ConsumerState<HomeShellPage>
|
|||
}
|
||||
|
||||
// 2. 检查是否在合同/KYC页面
|
||||
// 使用 GoRouter.of(context) 获取全局路由状态,而不是 GoRouterState.of(context)
|
||||
// 因为 GoRouterState.of(context) 只能获取到 ShellRoute 内的路由状态
|
||||
// 当用户导航到顶级路由(如 /contract-signing/:orderNo)时无法正确检测
|
||||
// 使用 appRouterProvider 获取全局路由状态
|
||||
try {
|
||||
final router = GoRouter.of(context);
|
||||
final router = ref.read(appRouterProvider);
|
||||
final location = router.routerDelegate.currentConfiguration.uri.path;
|
||||
debugPrint('[HomeShellPage] 当前路由: $location');
|
||||
debugPrint('[HomeShellPage] 当前路由(provider): $location');
|
||||
// 合同签署相关页面
|
||||
if (location.startsWith('/contract-signing')) return true;
|
||||
// KYC 相关页面
|
||||
|
|
|
|||
Loading…
Reference in New Issue