From b40cd40eae220820bc79bac8c7c60d9dfb31395e Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 26 Dec 2025 00:06:17 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile-app):=20=E4=BD=BF=E7=94=A8=20appRout?= =?UTF-8?q?erProvider=20=E8=8E=B7=E5=8F=96=E5=85=A8=E5=B1=80=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改用 ref.read(appRouterProvider) 替代 GoRouter.of(context), 确保能正确获取到当前的全局路由路径。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../home/presentation/pages/home_shell_page.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 c00d7256..7953ff74 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 @@ -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 } // 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 相关页面