diff --git a/frontend/mining-app/lib/core/router/app_router.dart b/frontend/mining-app/lib/core/router/app_router.dart index 1f6eaa11..9f5e13e0 100644 --- a/frontend/mining-app/lib/core/router/app_router.dart +++ b/frontend/mining-app/lib/core/router/app_router.dart @@ -6,7 +6,6 @@ import '../../presentation/pages/auth/login_page.dart'; import '../../presentation/pages/auth/register_page.dart'; import '../../presentation/pages/auth/forgot_password_page.dart'; import '../../presentation/pages/auth/change_password_page.dart'; -import '../../presentation/pages/home/home_page.dart'; import '../../presentation/pages/contribution/contribution_page.dart'; import '../../presentation/pages/trading/trading_page.dart'; import '../../presentation/pages/asset/asset_page.dart'; @@ -99,10 +98,6 @@ final appRouterProvider = Provider((ref) { ShellRoute( builder: (context, state, child) => MainShell(child: child), routes: [ - GoRoute( - path: Routes.home, - builder: (context, state) => const HomePage(), - ), GoRoute( path: Routes.contribution, builder: (context, state) => const ContributionPage(), diff --git a/frontend/mining-app/lib/core/router/routes.dart b/frontend/mining-app/lib/core/router/routes.dart index dd954141..ef0c71bd 100644 --- a/frontend/mining-app/lib/core/router/routes.dart +++ b/frontend/mining-app/lib/core/router/routes.dart @@ -4,7 +4,6 @@ class Routes { static const String register = '/register'; static const String forgotPassword = '/forgot-password'; static const String changePassword = '/change-password'; - static const String home = '/home'; static const String contribution = '/contribution'; static const String trading = '/trading'; static const String asset = '/asset'; diff --git a/frontend/mining-app/lib/presentation/pages/home/home_page.dart b/frontend/mining-app/lib/presentation/pages/home/home_page.dart deleted file mode 100644 index 495eb057..00000000 --- a/frontend/mining-app/lib/presentation/pages/home/home_page.dart +++ /dev/null @@ -1,135 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../../../core/constants/app_colors.dart'; -import '../../../core/utils/format_utils.dart'; -import '../../providers/user_providers.dart'; -import '../../providers/mining_providers.dart'; -import 'widgets/asset_card.dart'; -import 'widgets/price_card.dart'; -import 'widgets/quick_actions.dart'; - -class HomePage extends ConsumerWidget { - const HomePage({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final user = ref.watch(userNotifierProvider); - final accountSequence = user.accountSequence ?? ''; - - return Scaffold( - appBar: AppBar( - title: const Text('榴莲挖矿'), - backgroundColor: AppColors.primary, - foregroundColor: Colors.white, - actions: [ - IconButton( - icon: const Icon(Icons.notifications_outlined), - onPressed: () {}, - ), - ], - ), - body: RefreshIndicator( - onRefresh: () async { - ref.invalidate(shareAccountProvider(accountSequence)); - ref.invalidate(globalStateProvider); - }, - child: SingleChildScrollView( - physics: const AlwaysScrollableScrollPhysics(), - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // 资产卡片 - AssetCard(accountSequence: accountSequence), - - const SizedBox(height: 16), - - // 当前价格 - const PriceCard(), - - const SizedBox(height: 24), - - // 快捷操作 - const Text( - '快捷操作', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 12), - const QuickActions(), - - const SizedBox(height: 24), - - // 全网数据 - const Text( - '全网数据', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 12), - _buildGlobalStats(ref), - ], - ), - ), - ), - ); - } - - Widget _buildGlobalStats(WidgetRef ref) { - final globalState = ref.watch(globalStateProvider); - - return globalState.when( - data: (state) { - if (state == null) return const SizedBox.shrink(); - return Card( - child: Padding( - padding: const EdgeInsets.all(16), - child: Column( - children: [ - _buildStatRow('全网算力', formatCompact(state.networkContribution)), - const Divider(), - _buildStatRow('已分配', formatCompact(state.totalDistributed)), - const Divider(), - _buildStatRow('已销毁', formatCompact(state.totalBurned)), - const Divider(), - _buildStatRow('流通池', formatCompact(state.circulationPool)), - ], - ), - ), - ); - }, - loading: () => const Card( - child: Padding( - padding: EdgeInsets.all(32), - child: Center(child: CircularProgressIndicator()), - ), - ), - error: (_, __) => const Card( - child: Padding( - padding: EdgeInsets.all(32), - child: Center(child: Text('加载失败')), - ), - ), - ); - } - - Widget _buildStatRow(String label, String value) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(label, style: const TextStyle(color: AppColors.textSecondary)), - Text( - value, - style: const TextStyle(fontWeight: FontWeight.w500), - ), - ], - ), - ); - } -} diff --git a/frontend/mining-app/lib/presentation/pages/home/widgets/asset_card.dart b/frontend/mining-app/lib/presentation/pages/home/widgets/asset_card.dart deleted file mode 100644 index 5c2ccb00..00000000 --- a/frontend/mining-app/lib/presentation/pages/home/widgets/asset_card.dart +++ /dev/null @@ -1,110 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../../../../core/constants/app_colors.dart'; -import '../../../../core/utils/format_utils.dart'; -import '../../../providers/mining_providers.dart'; - -class AssetCard extends ConsumerWidget { - final String accountSequence; - - const AssetCard({super.key, required this.accountSequence}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final accountAsync = ref.watch(shareAccountProvider(accountSequence)); - - return Container( - width: double.infinity, - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [AppColors.primary, Color(0xFF16A34A)], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: AppColors.primary.withOpacity(0.3), - blurRadius: 20, - offset: const Offset(0, 10), - ), - ], - ), - child: accountAsync.when( - data: (account) { - if (account == null) { - return const Center( - child: Text('暂无数据', style: TextStyle(color: Colors.white70)), - ); - } - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( - '我的积分股', - style: TextStyle(color: Colors.white70, fontSize: 14), - ), - const SizedBox(height: 8), - Text( - formatAmount(account.totalBalance), - style: const TextStyle( - color: Colors.white, - fontSize: 36, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 20), - Row( - children: [ - Expanded( - child: _buildBalanceItem('挖矿账户', account.miningBalance), - ), - Expanded( - child: _buildBalanceItem('交易账户', account.tradingBalance), - ), - Expanded( - child: _buildBalanceItem('冻结', account.frozenBalance), - ), - ], - ), - ], - ); - }, - loading: () => const SizedBox( - height: 140, - child: Center( - child: CircularProgressIndicator(color: Colors.white), - ), - ), - error: (_, __) => const SizedBox( - height: 140, - child: Center( - child: Text('加载失败', style: TextStyle(color: Colors.white70)), - ), - ), - ), - ); - } - - Widget _buildBalanceItem(String label, String value) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - label, - style: const TextStyle(color: Colors.white60, fontSize: 12), - ), - const SizedBox(height: 4), - Text( - formatAmount(value), - style: const TextStyle( - color: Colors.white, - fontSize: 16, - fontWeight: FontWeight.w500, - ), - ), - ], - ); - } -} diff --git a/frontend/mining-app/lib/presentation/pages/home/widgets/price_card.dart b/frontend/mining-app/lib/presentation/pages/home/widgets/price_card.dart deleted file mode 100644 index 4c8893a3..00000000 --- a/frontend/mining-app/lib/presentation/pages/home/widgets/price_card.dart +++ /dev/null @@ -1,95 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../../../../core/constants/app_colors.dart'; -import '../../../../core/utils/format_utils.dart'; -import '../../../providers/mining_providers.dart'; - -class PriceCard extends ConsumerWidget { - const PriceCard({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final globalState = ref.watch(globalStateProvider); - - return Card( - child: Padding( - padding: const EdgeInsets.all(16), - child: globalState.when( - data: (state) { - if (state == null) { - return const Center(child: Text('暂无数据')); - } - final isPriceUp = state.isPriceUp; - return Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( - '当前价格', - style: TextStyle( - color: AppColors.textSecondary, - fontSize: 12, - ), - ), - const SizedBox(height: 4), - Text( - formatPrice(state.currentPrice), - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, - color: isPriceUp ? AppColors.up : AppColors.down, - ), - ), - const Text( - '绿积分/股', - style: TextStyle( - color: AppColors.textMuted, - fontSize: 12, - ), - ), - ], - ), - ), - Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), - decoration: BoxDecoration( - color: (isPriceUp ? AppColors.up : AppColors.down).withOpacity(0.1), - borderRadius: BorderRadius.circular(20), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - isPriceUp ? Icons.arrow_upward : Icons.arrow_downward, - size: 16, - color: isPriceUp ? AppColors.up : AppColors.down, - ), - const SizedBox(width: 4), - Text( - formatPercent(state.priceChange24h), - style: TextStyle( - color: isPriceUp ? AppColors.up : AppColors.down, - fontWeight: FontWeight.w500, - ), - ), - ], - ), - ), - ], - ); - }, - loading: () => const SizedBox( - height: 80, - child: Center(child: CircularProgressIndicator()), - ), - error: (_, __) => const SizedBox( - height: 80, - child: Center(child: Text('加载失败')), - ), - ), - ), - ); - } -} diff --git a/frontend/mining-app/lib/presentation/pages/home/widgets/quick_actions.dart b/frontend/mining-app/lib/presentation/pages/home/widgets/quick_actions.dart deleted file mode 100644 index 604b9206..00000000 --- a/frontend/mining-app/lib/presentation/pages/home/widgets/quick_actions.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import '../../../../core/constants/app_colors.dart'; -import '../../../../core/router/routes.dart'; - -class QuickActions extends StatelessWidget { - const QuickActions({super.key}); - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - child: _buildActionCard( - context, - icon: Icons.trending_up, - label: '查看算力', - color: AppColors.primary, - onTap: () => context.go(Routes.contribution), - ), - ), - const SizedBox(width: 12), - Expanded( - child: _buildActionCard( - context, - icon: Icons.swap_horiz, - label: '去兑换', - color: AppColors.secondary, - onTap: () => context.go(Routes.trading), - ), - ), - const SizedBox(width: 12), - Expanded( - child: _buildActionCard( - context, - icon: Icons.history, - label: '挖矿记录', - color: AppColors.warning, - onTap: () { - // TODO: Navigate to mining records - }, - ), - ), - ], - ); - } - - Widget _buildActionCard( - BuildContext context, { - required IconData icon, - required String label, - required Color color, - required VoidCallback onTap, - }) { - return InkWell( - onTap: onTap, - borderRadius: BorderRadius.circular(12), - child: Container( - padding: const EdgeInsets.symmetric(vertical: 16), - decoration: BoxDecoration( - color: color.withOpacity(0.1), - borderRadius: BorderRadius.circular(12), - ), - child: Column( - children: [ - Icon(icon, color: color, size: 28), - const SizedBox(height: 8), - Text( - label, - style: TextStyle( - color: color, - fontSize: 12, - fontWeight: FontWeight.w500, - ), - ), - ], - ), - ), - ); - } -} 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 e7ed9be7..cb0387ba 100644 --- a/frontend/mining-app/lib/presentation/pages/splash/splash_page.dart +++ b/frontend/mining-app/lib/presentation/pages/splash/splash_page.dart @@ -32,7 +32,7 @@ class _SplashPageState extends ConsumerState { try { await ref.read(userNotifierProvider.notifier).refreshTokenIfNeeded(); if (mounted) { - context.go(Routes.home); + context.go(Routes.contribution); } } catch (e) { // token刷新失败,跳转到登录页