|
|
|
@ -4,7 +4,6 @@ import 'package:get/get.dart'; |
|
|
|
import '../controllers/translation_stats_controller.dart'; |
|
|
|
import '../../../core/theme/app_colors.dart'; |
|
|
|
|
|
|
|
/// 翻译统计页面 |
|
|
|
class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
const TranslationStatsView({Key? key}) : super(key: key); |
|
|
|
|
|
|
|
@ -21,7 +20,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建应用栏 |
|
|
|
PreferredSizeWidget _buildAppBar(bool isDarkMode) { |
|
|
|
return AppBar( |
|
|
|
leading: IconButton( |
|
|
|
@ -35,7 +33,7 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
backgroundColor: isDarkMode ? AppColors.darkBackground : Colors.white, |
|
|
|
elevation: 0.5, |
|
|
|
title: Text( |
|
|
|
'翻译统计', // translationStats |
|
|
|
'翻译统计', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 17.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
@ -44,7 +42,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
), |
|
|
|
centerTitle: true, |
|
|
|
actions: [ |
|
|
|
// 刷新按钮 |
|
|
|
IconButton( |
|
|
|
icon: Icon( |
|
|
|
Icons.refresh, |
|
|
|
@ -52,7 +49,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
), |
|
|
|
onPressed: controller.refreshData, |
|
|
|
), |
|
|
|
// 更多操作菜单 |
|
|
|
PopupMenuButton<String>( |
|
|
|
icon: Icon( |
|
|
|
Icons.more_vert, |
|
|
|
@ -68,12 +64,12 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
break; |
|
|
|
} |
|
|
|
}, |
|
|
|
itemBuilder: (context) => [ |
|
|
|
const PopupMenuItem( |
|
|
|
itemBuilder: (context) => const [ |
|
|
|
PopupMenuItem( |
|
|
|
value: 'cleanup', |
|
|
|
child: Text('清理过期数据'), |
|
|
|
), |
|
|
|
const PopupMenuItem( |
|
|
|
PopupMenuItem( |
|
|
|
value: 'export', |
|
|
|
child: Text('导出数据'), |
|
|
|
), |
|
|
|
@ -83,42 +79,32 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建加载组件 |
|
|
|
Widget _buildLoadingWidget() { |
|
|
|
return const Center( |
|
|
|
child: CircularProgressIndicator(), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建主体内容 |
|
|
|
Widget _buildBody(bool isDarkMode) { |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
// 时间范围选择器 |
|
|
|
_buildTimeRangeSelector(isDarkMode), |
|
|
|
// 统计内容 |
|
|
|
Expanded( |
|
|
|
child: SingleChildScrollView( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
// 实时统计卡片 |
|
|
|
if (controller.selectedTabIndex.value == 0) |
|
|
|
_buildRealtimeStatsCard(isDarkMode), |
|
|
|
SizedBox(height: 16.h), |
|
|
|
// 概览统计卡片 |
|
|
|
_buildOverviewCard(isDarkMode), |
|
|
|
SizedBox(height: 16.h), |
|
|
|
// API调用统计 |
|
|
|
_buildApiCallsCard(isDarkMode), |
|
|
|
SizedBox(height: 16.h), |
|
|
|
// 数据量统计 |
|
|
|
_buildDataVolumeCard(isDarkMode), |
|
|
|
SizedBox(height: 16.h), |
|
|
|
// 成本统计 |
|
|
|
_buildCostCard(isDarkMode), |
|
|
|
SizedBox(height: 16.h), |
|
|
|
// 使用行为统计 |
|
|
|
_buildUsageBehaviorCard(isDarkMode), |
|
|
|
], |
|
|
|
), |
|
|
|
@ -128,7 +114,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建时间范围选择器 |
|
|
|
Widget _buildTimeRangeSelector(bool isDarkMode) { |
|
|
|
return Container( |
|
|
|
margin: EdgeInsets.all(16.w), |
|
|
|
@ -137,7 +122,7 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withOpacity(0.05), |
|
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
|
blurRadius: 10, |
|
|
|
offset: const Offset(0, 2), |
|
|
|
), |
|
|
|
@ -154,7 +139,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建时间范围标签 |
|
|
|
Widget _buildTimeRangeTab(String title, int index, bool isDarkMode) { |
|
|
|
final isSelected = controller.selectedTabIndex.value == index; |
|
|
|
|
|
|
|
@ -185,7 +169,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建实时统计卡片 |
|
|
|
Widget _buildRealtimeStatsCard(bool isDarkMode) { |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
@ -194,7 +177,7 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withOpacity(0.05), |
|
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
|
blurRadius: 10, |
|
|
|
offset: const Offset(0, 2), |
|
|
|
), |
|
|
|
@ -272,7 +255,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建概览卡片 |
|
|
|
Widget _buildOverviewCard(bool isDarkMode) { |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
@ -281,7 +263,7 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withOpacity(0.05), |
|
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
|
blurRadius: 10, |
|
|
|
offset: const Offset(0, 2), |
|
|
|
), |
|
|
|
@ -358,7 +340,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建统计项 |
|
|
|
Widget _buildStatItem( |
|
|
|
String label, String value, IconData icon, bool isDarkMode) { |
|
|
|
return Column( |
|
|
|
@ -389,7 +370,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建API调用统计卡片 |
|
|
|
Widget _buildApiCallsCard(bool isDarkMode) { |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
@ -398,7 +378,7 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withOpacity(0.05), |
|
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
|
blurRadius: 10, |
|
|
|
offset: const Offset(0, 2), |
|
|
|
), |
|
|
|
@ -452,7 +432,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建API调用行 |
|
|
|
Widget _buildApiCallRow( |
|
|
|
String label, int count, IconData icon, bool isDarkMode) { |
|
|
|
return Row( |
|
|
|
@ -484,7 +463,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建数据量统计卡片 |
|
|
|
Widget _buildDataVolumeCard(bool isDarkMode) { |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
@ -493,7 +471,7 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withOpacity(0.05), |
|
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
|
blurRadius: 10, |
|
|
|
offset: const Offset(0, 2), |
|
|
|
), |
|
|
|
@ -575,7 +553,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建成本统计卡片 |
|
|
|
Widget _buildCostCard(bool isDarkMode) { |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
@ -584,7 +561,7 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withOpacity(0.05), |
|
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
|
blurRadius: 10, |
|
|
|
offset: const Offset(0, 2), |
|
|
|
), |
|
|
|
@ -614,11 +591,10 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
SizedBox(height: 16.h), |
|
|
|
Obx(() => Column( |
|
|
|
children: [ |
|
|
|
// 当前成本 |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.all(12.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: AppColors.primary.withOpacity(0.1), |
|
|
|
color: AppColors.primary.withValues(alpha: 0.1), |
|
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
|
), |
|
|
|
child: Row( |
|
|
|
@ -645,7 +621,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 12.h), |
|
|
|
// 预警阈值 |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
children: [ |
|
|
|
@ -694,7 +669,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建使用行为统计卡片 |
|
|
|
Widget _buildUsageBehaviorCard(bool isDarkMode) { |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
@ -703,7 +677,7 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withOpacity(0.05), |
|
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
|
blurRadius: 10, |
|
|
|
offset: const Offset(0, 2), |
|
|
|
), |
|
|
|
@ -733,7 +707,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
SizedBox(height: 16.h), |
|
|
|
Obx(() => Column( |
|
|
|
children: [ |
|
|
|
// 最常用语言对 |
|
|
|
_buildUsageBehaviorRow( |
|
|
|
'最常用语言对', |
|
|
|
controller.currentStats.mostUsedLanguagePair, |
|
|
|
@ -741,7 +714,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
isDarkMode, |
|
|
|
), |
|
|
|
SizedBox(height: 12.h), |
|
|
|
// 最常用翻译模式 |
|
|
|
_buildUsageBehaviorRow( |
|
|
|
'最常用模式', |
|
|
|
controller.currentStats.mostUsedMode, |
|
|
|
@ -755,7 +727,6 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建使用行为行 |
|
|
|
Widget _buildUsageBehaviorRow( |
|
|
|
String label, String value, IconData icon, bool isDarkMode) { |
|
|
|
return Row( |
|
|
|
@ -786,4 +757,4 @@ class TranslationStatsView extends GetView<TranslationStatsController> { |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |