From 41f142124b72436c32c6c92b664d0a333562ab49 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 12 Jan 2026 19:32:31 -0800 Subject: [PATCH] fix(mining-app): update splash page theme and fix token refresh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update splash_page.dart to orange theme (#FF6B00) matching other pages - Change app name from "榴莲挖矿" to "榴莲生态" - Fix refreshTokenIfNeeded to properly throw on failure instead of silently calling logout (which caused Riverpod ref errors) - Clear local storage directly on refresh failure without remote API call Co-Authored-By: Claude Opus 4.5 --- .../pages/splash/splash_page.dart | 31 ++++++++++++------- .../providers/user_providers.dart | 9 ++++-- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/frontend/mining-app/lib/presentation/pages/splash/splash_page.dart b/frontend/mining-app/lib/presentation/pages/splash/splash_page.dart index cb0387ba..4463565b 100644 --- a/frontend/mining-app/lib/presentation/pages/splash/splash_page.dart +++ b/frontend/mining-app/lib/presentation/pages/splash/splash_page.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import '../../../core/router/routes.dart'; -import '../../../core/constants/app_colors.dart'; import '../../providers/user_providers.dart'; class SplashPage extends ConsumerStatefulWidget { @@ -13,6 +12,12 @@ class SplashPage extends ConsumerStatefulWidget { } class _SplashPageState extends ConsumerState { + // 设计色彩 - 与导航页面统一 + static const Color _orange = Color(0xFFFF6B00); + static const Color _darkText = Color(0xFF1F2937); + static const Color _grayText = Color(0xFF6B7280); + static const Color _serenade = Color(0xFFFFF7ED); + @override void initState() { super.initState(); @@ -49,7 +54,7 @@ class _SplashPageState extends ConsumerState { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: AppColors.primary, + backgroundColor: Colors.white, body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -58,20 +63,20 @@ class _SplashPageState extends ConsumerState { width: 100, height: 100, decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), + color: _serenade, + borderRadius: BorderRadius.circular(24), ), child: const Icon( Icons.eco, size: 60, - color: AppColors.primary, + color: _orange, ), ), const SizedBox(height: 24), const Text( - '榴莲挖矿', + '榴莲生态', style: TextStyle( - color: Colors.white, + color: _darkText, fontSize: 28, fontWeight: FontWeight.bold, ), @@ -80,14 +85,18 @@ class _SplashPageState extends ConsumerState { const Text( '绿色财富 共享未来', style: TextStyle( - color: Colors.white70, + color: _grayText, fontSize: 16, ), ), const SizedBox(height: 48), - const CircularProgressIndicator( - color: Colors.white, - strokeWidth: 2, + const SizedBox( + width: 24, + height: 24, + child: CircularProgressIndicator( + color: _orange, + strokeWidth: 2, + ), ), ], ), diff --git a/frontend/mining-app/lib/presentation/providers/user_providers.dart b/frontend/mining-app/lib/presentation/providers/user_providers.dart index 212d66f6..99a2aebd 100644 --- a/frontend/mining-app/lib/presentation/providers/user_providers.dart +++ b/frontend/mining-app/lib/presentation/providers/user_providers.dart @@ -181,14 +181,19 @@ class UserNotifier extends StateNotifier { } Future refreshTokenIfNeeded() async { - if (state.refreshToken == null) return; + if (state.refreshToken == null) { + throw Exception('No refresh token available'); + } try { final newAccessToken = await _authDataSource.refreshToken(state.refreshToken!); final prefs = await SharedPreferences.getInstance(); await prefs.setString('access_token', newAccessToken); state = state.copyWith(accessToken: newAccessToken); } catch (e) { - await logout(); + // 清除本地存储,不调用远程logout API(可能网络不可用) + await _clearStorage(); + state = UserState(); + rethrow; } }