init
This commit is contained in:
45
lib/routes/app_router.dart
Normal file
45
lib/routes/app_router.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:chat/routes/app_routes.dart';
|
||||
import 'package:chat/routes/auth_routes.dart';
|
||||
import 'package:chat/views/home/index_page.dart';
|
||||
import 'package:chat/views/public/app_page.dart';
|
||||
import 'package:chat/views/public/scan_page.dart';
|
||||
import 'package:chat/views/public/transit_page.dart';
|
||||
import 'package:chat/views/public/unknown_page.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AppRouter {
|
||||
// 引导页
|
||||
static const String transitRoute = AppRoutes.transit;
|
||||
// 未知页面,返回主页
|
||||
static final GetPage unknownRoute = GetPage(
|
||||
name: AppRoutes.notfound,
|
||||
page: () => const UnknownPage(),
|
||||
);
|
||||
|
||||
// 路由页面
|
||||
static final List<GetPage<dynamic>> getPages = [
|
||||
/// 过渡页面
|
||||
GetPage(
|
||||
name: AppRoutes.transit,
|
||||
page: () => const TransitPage(),
|
||||
),
|
||||
|
||||
GetPage(
|
||||
name: AppRoutes.app,
|
||||
page: () => AppPage(),
|
||||
),
|
||||
|
||||
/// 首页
|
||||
GetPage(
|
||||
name: AppRoutes.home,
|
||||
page: () => const HomePage(),
|
||||
),
|
||||
|
||||
GetPage(
|
||||
name: AppRoutes.scan,
|
||||
page: () => const ScanPage(),
|
||||
),
|
||||
|
||||
AuthRoutes.router,
|
||||
];
|
||||
}
|
||||
17
lib/routes/app_routes.dart
Normal file
17
lib/routes/app_routes.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
/// 这里是为了定义别名路由的名称,
|
||||
/// 具体映射关系,在app_router 的 getPages 中实现
|
||||
abstract class AppRoutes {
|
||||
/// 过渡页
|
||||
static const String transit = '/transit';
|
||||
|
||||
/// 找不到页面的时候
|
||||
static const String notfound = '/notfound';
|
||||
|
||||
/// 根页面
|
||||
static const String app = '/';
|
||||
|
||||
/// 首页
|
||||
static const String home = '/home';
|
||||
|
||||
static const String scan = '/scan';
|
||||
}
|
||||
16
lib/routes/auth_routes.dart
Normal file
16
lib/routes/auth_routes.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:chat/middleware/auth_middleware.dart';
|
||||
import 'package:chat/views/auth/index_page.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class AuthRoutes {
|
||||
/// 身份验证页面
|
||||
static const String index = '/auth';
|
||||
|
||||
static GetPage router = GetPage(
|
||||
name: AuthRoutes.index,
|
||||
middlewares: [
|
||||
EnsureNotAuthMiddleware(),
|
||||
],
|
||||
page: () => const AuthPage(),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user