fix: 启动页遮住登录/首页初始态,消除深色模式黑闪
- 新增 SplashPage + appReadyProvider/_BootGate:启动闸门将启动页覆盖在最上层, 直到 auth 判定完成且今日健康卡数据就绪,遮住登录页闪现与首页对话流初始态 - auth 初始状态改为 isLoading=true,无 token 时再置 false - values-night/styles.xml 改为亮色白底,消除深色模式下 Flutter 初始化期间的黑色窗口背景 - 带 8 秒安全兜底,避免离线时卡在启动页
This commit is contained in:
@@ -35,13 +35,18 @@ class AuthNotifier extends Notifier<AuthState> {
|
||||
@override
|
||||
AuthState build() {
|
||||
_checkAuth();
|
||||
return const AuthState(isLoggedIn: false, isLoading: false);
|
||||
// 初始为"加载中",让启动闸门显示 Splash 盖住登录页/首页初始态
|
||||
return const AuthState(isLoggedIn: false, isLoading: true);
|
||||
}
|
||||
|
||||
Future<void> _checkAuth() async {
|
||||
final db = ref.read(localDbProvider);
|
||||
final refresh = await db.read('refresh_token');
|
||||
if (refresh == null) return; // 无token,保持 isLoggedIn: false
|
||||
if (refresh == null) {
|
||||
// 无 token:判定完成、未登录
|
||||
state = const AuthState(isLoggedIn: false, isLoading: false);
|
||||
return;
|
||||
}
|
||||
|
||||
state = const AuthState(isLoading: true);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user