import 'package:go_router/go_router.dart';

import '../../features/auth/presentation/pages/login_page.dart';
import '../../features/auth/presentation/pages/splash_page.dart';
import '../../features/connection/presentation/pages/control_page.dart';
import '../../features/connection/presentation/pages/setup_page.dart';

/// 应用路由。
///
/// - `/splash`：启动页，恢复并校验令牌后重定向（初始路由）
/// - `/login`：登录页，支持通过 `message` 查询参数展示失效提示
/// - `/`：连接设置页
/// - `/control`：控制面板页
final appRouter = GoRouter(
  initialLocation: '/splash',
  routes: [
    GoRoute(
      path: '/splash',
      name: 'splash',
      builder: (context, state) => const SplashPage(),
    ),
    GoRoute(
      path: '/login',
      name: 'login',
      builder: (context, state) => LoginPage(
        message: state.uri.queryParameters['message'],
      ),
    ),
    GoRoute(
      path: '/',
      name: 'setup',
      builder: (context, state) => const SetupPage(),
    ),
    GoRoute(
      path: '/control',
      name: 'control',
      builder: (context, state) => const ControlPage(),
    ),
  ],
);
