import 'package:go_router/go_router.dart'; import '../../features/auth/presentation/login_page.dart'; import '../../features/auth/presentation/register_page.dart'; import '../../features/auth/presentation/forgot_password_page.dart'; import '../../features/auth/presentation/legal_document_page.dart'; import '../../features/auth/presentation/splash_page.dart'; import '../../features/home/presentation/home_page.dart'; import '../../features/home/presentation/home_tab.dart'; import '../../features/messages/presentation/messages_tab.dart'; import '../../features/profile/presentation/profile_tab.dart'; import '../../features/album/presentation/album_page.dart'; import '../../features/alarm/presentation/alarm_page.dart'; import '../../features/contacts/presentation/contacts_page.dart'; import '../../features/apps/presentation/apps_page.dart'; /// 应用路由定义(GoRouter)。 /// /// - /splash 启动页,依据登录态决定首跳 /// - /login /register 认证流程 /// - /home Shell 路由,承载底部 Tab(首页 / 管理 / 我的) /// - /album /alarm /contacts /apps 管理页横版菜单进入的子页面(无底部 Tab) GoRouter buildAppRouter() { return GoRouter( initialLocation: '/splash', routes: [ GoRoute( path: '/splash', builder: (context, state) => const SplashPage(), ), GoRoute( path: '/login', builder: (context, state) => const LoginPage(), ), GoRoute( path: '/register', builder: (context, state) => const RegisterPage(), ), GoRoute( path: '/forgot-password', builder: (context, state) => const ForgotPasswordPage(), ), GoRoute( path: '/legal', builder: (context, state) => LegalDocumentPage.fromExtra(state.extra), ), GoRoute( path: '/album', builder: (context, state) => const AlbumPage(), ), GoRoute( path: '/alarm', builder: (context, state) => const AlarmPage(), ), GoRoute( path: '/contacts', builder: (context, state) => const ContactsPage(), ), GoRoute( path: '/apps', builder: (context, state) => const AppsPage(), ), StatefulShellRoute.indexedStack( builder: (context, state, shell) => HomePage(child: shell), branches: [ StatefulShellBranch( routes: [ GoRoute( path: '/home', builder: (context, state) => const HomeTab(), ), ], ), StatefulShellBranch( routes: [ GoRoute( path: '/messages', builder: (context, state) => const MessagesTab(), ), ], ), StatefulShellBranch( routes: [ GoRoute( path: '/profile', builder: (context, state) => const ProfileTab(), ), ], ), ], ), ], ); }