启动动画和登录页面的动画

This commit is contained in:
2026-09-23 16:48:48 +08:00
parent 32397f8899
commit d230279f4f
3 changed files with 229 additions and 115 deletions

View File

@@ -30,13 +30,19 @@ GoRouter createRouter(AuthCubit authCubit) {
return GoRouter(
navigatorKey: navigatorKey, // 🔥 绑定全局 navigatorKey,使异地登录弹窗能获取 context
initialLocation: RoutePaths.login,
initialLocation: RoutePaths.splash,
refreshListenable: GoRouterRefreshStream(authCubit.stream),
redirect: (context, state) {
final loggedIn = authCubit.state is AuthAuthenticated;
final onSplash = state.matchedLocation == RoutePaths.splash;
final loggingIn = state.matchedLocation == RoutePaths.login;
final registering = state.matchedLocation == RoutePaths.register;
// 启动屏:交给 SplashPage 自己根据就绪信号跳转,路由层不干预
if (onSplash) {
return null;
}
// 如果未登录,只允许访问 login 和 register 页面
if (!loggedIn && !loggingIn && !registering) {
return RoutePaths.login;