From ce75e68d5e3fcf1843096bab05e65bfb85d74336 Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 25 Dec 2025 23:38:55 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile-app):=20=E4=BF=AE=E5=A4=8D=E5=90=88?= =?UTF-8?q?=E5=90=8C=E7=AD=BE=E7=BD=B2=E9=A1=B5=E9=9D=A2=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E4=BB=8D=E5=BC=B9=E7=AA=97=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用 GoRouter.of(context).routerDelegate.currentConfiguration 获取全局路由状态, 而不是 GoRouterState.of(context),因为后者只能获取 ShellRoute 内部的路由状态, 当用户在顶级路由(如 /contract-signing/:orderNo)时无法正确检测。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../features/home/presentation/pages/home_shell_page.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 ab4d5c88..c00d7256 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 @@ -109,14 +109,20 @@ class _HomeShellPageState extends ConsumerState } // 2. 检查是否在合同/KYC页面 + // 使用 GoRouter.of(context) 获取全局路由状态,而不是 GoRouterState.of(context) + // 因为 GoRouterState.of(context) 只能获取到 ShellRoute 内的路由状态 + // 当用户导航到顶级路由(如 /contract-signing/:orderNo)时无法正确检测 try { - final location = GoRouterState.of(context).uri.path; + final router = GoRouter.of(context); + final location = router.routerDelegate.currentConfiguration.uri.path; + debugPrint('[HomeShellPage] 当前路由: $location'); // 合同签署相关页面 if (location.startsWith('/contract-signing')) return true; // KYC 相关页面 if (location.startsWith('/kyc')) return true; return false; } catch (e) { + debugPrint('[HomeShellPage] 获取路由状态失败: $e'); return false; } }