Files
2026-09-15 15:44:13 +07:00

34 lines
1.1 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hgdj/tools_base/global_store/store.dart';
import '../hj_page/mine/mine_setting/mine_password_logic.dart';
import '../hj_page/mine/mine_setting/mine_password_page.dart';
import '../hj_page/splash/splash_page.dart';
/// 只保留这两条:其余页面一律 Get.to(() => XxxPage())。
/// SplashPage 是 initialRoute
/// MinePasswordPage 是中间件 redirect 的目标,只能按名解析。
class AppRoutes {
static final routePages = [
GetPage(
name: SplashPage.routeName,
page: () => const SplashPage(),
middlewares: [SplashPasswordMiddleware()],
),
GetPage(
name: MinePasswordPage.routeName,
page: () => const MinePasswordPage()), //设置锁屏密码
];
}
class SplashPasswordMiddleware extends GetMiddleware {
@override
RouteSettings? redirect(String? route) {
if (globalStore.password.isEmpty || globalStore.isUnlocked)
return super.redirect(route);
return RouteSettings(
name: MinePasswordPage.routeName, arguments: MinePasswordType.check);
}
}