fix(mining-app): update splash page theme and fix token refresh

- 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 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-12 19:32:31 -08:00
parent 9037c2da97
commit 41f142124b
2 changed files with 27 additions and 13 deletions

View File

@ -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<SplashPage> {
// -
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<SplashPage> {
@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<SplashPage> {
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<SplashPage> {
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,
),
),
],
),

View File

@ -181,14 +181,19 @@ class UserNotifier extends StateNotifier<UserState> {
}
Future<void> 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;
}
}