|
|
|
@ -142,9 +142,9 @@ class TranslationDetailView extends GetView<TranslationDetailController> { |
|
|
|
if (controller.selectedTabIndex.value == 0) |
|
|
|
..._buildOriginalRecords(isDarkMode) |
|
|
|
else |
|
|
|
_buildSummaryWidget(isDarkMode), |
|
|
|
//_buildSummaryWidget(isDarkMode), |
|
|
|
|
|
|
|
SizedBox(height: 24.h), |
|
|
|
SizedBox(height: 24.h), |
|
|
|
], |
|
|
|
); |
|
|
|
}), |
|
|
|
@ -323,23 +323,23 @@ class TranslationDetailView extends GetView<TranslationDetailController> { |
|
|
|
} |
|
|
|
|
|
|
|
// 构建总结视图 |
|
|
|
Widget _buildSummaryWidget(bool isDarkMode) { |
|
|
|
final String combinedSourceText = _getCombinedSourceText(); |
|
|
|
// Widget _buildSummaryWidget(bool isDarkMode) { |
|
|
|
// final String combinedSourceText = _getCombinedSourceText(); |
|
|
|
|
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
// 摘要内容容器 |
|
|
|
_buildSummaryContainer(isDarkMode), |
|
|
|
// return Column( |
|
|
|
// children: [ |
|
|
|
// // 摘要内容容器 |
|
|
|
// _buildSummaryContainer(isDarkMode), |
|
|
|
|
|
|
|
// 提取摘要按钮 |
|
|
|
Obx(() => _buildExtractSummaryButton(combinedSourceText, isDarkMode)), |
|
|
|
// // 提取摘要按钮 |
|
|
|
// Obx(() => _buildExtractSummaryButton(combinedSourceText, isDarkMode)), |
|
|
|
|
|
|
|
// 重新生成按钮 |
|
|
|
Obx(() => |
|
|
|
_buildRegenerateSummaryButton(combinedSourceText, isDarkMode)), |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
// // 重新生成按钮 |
|
|
|
// Obx(() => |
|
|
|
// _buildRegenerateSummaryButton(combinedSourceText, isDarkMode)), |
|
|
|
// ], |
|
|
|
// ); |
|
|
|
// } |
|
|
|
|
|
|
|
// 构建摘要容器 |
|
|
|
Widget _buildSummaryContainer(bool isDarkMode) { |
|
|
|
@ -484,163 +484,163 @@ class TranslationDetailView extends GetView<TranslationDetailController> { |
|
|
|
} |
|
|
|
|
|
|
|
// 构建提取摘要按钮 |
|
|
|
Widget _buildExtractSummaryButton( |
|
|
|
String combinedSourceText, bool isDarkMode) { |
|
|
|
final bool isDisabled = controller.isGeneratingSummary.value || |
|
|
|
controller.summaryResult.value.isNotEmpty; |
|
|
|
|
|
|
|
return Container( |
|
|
|
width: double.infinity, |
|
|
|
margin: EdgeInsets.only(bottom: 16.h), |
|
|
|
child: ElevatedButton( |
|
|
|
onPressed: |
|
|
|
isDisabled ? null : () => _extractSummary(combinedSourceText), |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: isDarkMode ? AppColors.primary : Colors.blue, |
|
|
|
foregroundColor: Colors.white, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
), |
|
|
|
elevation: 0, |
|
|
|
disabledBackgroundColor: controller.isGeneratingSummary.value |
|
|
|
? isDarkMode |
|
|
|
? AppColors.primary.withAlpha(128) |
|
|
|
: Colors.blue.withAlpha(128) |
|
|
|
: Colors.grey.withAlpha(128), |
|
|
|
), |
|
|
|
child: controller.isGeneratingSummary.value |
|
|
|
? _buildGeneratingIndicator(isDarkMode) |
|
|
|
: Text( |
|
|
|
controller.summaryResult.value.isEmpty |
|
|
|
? 'extractSummary'.tr |
|
|
|
: 'summaryGenerated'.tr, // 提取摘要 : 已生成摘要 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
// Widget _buildExtractSummaryButton( |
|
|
|
// String combinedSourceText, bool isDarkMode) { |
|
|
|
// final bool isDisabled = controller.isGeneratingSummary.value || |
|
|
|
// controller.summaryResult.value.isNotEmpty; |
|
|
|
|
|
|
|
// return Container( |
|
|
|
// width: double.infinity, |
|
|
|
// margin: EdgeInsets.only(bottom: 16.h), |
|
|
|
// child: ElevatedButton( |
|
|
|
// onPressed: |
|
|
|
// isDisabled ? null : () => _extractSummary(combinedSourceText), |
|
|
|
// style: ElevatedButton.styleFrom( |
|
|
|
// backgroundColor: isDarkMode ? AppColors.primary : Colors.blue, |
|
|
|
// foregroundColor: Colors.white, |
|
|
|
// padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
// shape: RoundedRectangleBorder( |
|
|
|
// borderRadius: BorderRadius.circular(16.r), |
|
|
|
// ), |
|
|
|
// elevation: 0, |
|
|
|
// disabledBackgroundColor: controller.isGeneratingSummary.value |
|
|
|
// ? isDarkMode |
|
|
|
// ? AppColors.primary.withAlpha(128) |
|
|
|
// : Colors.blue.withAlpha(128) |
|
|
|
// : Colors.grey.withAlpha(128), |
|
|
|
// ), |
|
|
|
// child: controller.isGeneratingSummary.value |
|
|
|
// ? _buildGeneratingIndicator(isDarkMode) |
|
|
|
// : Text( |
|
|
|
// controller.summaryResult.value.isEmpty |
|
|
|
// ? 'extractSummary'.tr |
|
|
|
// : 'summaryGenerated'.tr, // 提取摘要 : 已生成摘要 |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 16.sp, |
|
|
|
// fontWeight: FontWeight.w600, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ); |
|
|
|
// } |
|
|
|
|
|
|
|
// 构建生成中指示器 |
|
|
|
Widget _buildGeneratingIndicator(bool isDarkMode) { |
|
|
|
return Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
SizedBox( |
|
|
|
width: 20.w, |
|
|
|
height: 20.h, |
|
|
|
child: CircularProgressIndicator( |
|
|
|
color: Colors.white, |
|
|
|
strokeWidth: 2.0, |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(width: 12.w), |
|
|
|
Text( |
|
|
|
'generating'.tr, // 生成中... |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
// Widget _buildGeneratingIndicator(bool isDarkMode) { |
|
|
|
// return Row( |
|
|
|
// mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
// children: [ |
|
|
|
// SizedBox( |
|
|
|
// width: 20.w, |
|
|
|
// height: 20.h, |
|
|
|
// child: CircularProgressIndicator( |
|
|
|
// color: Colors.white, |
|
|
|
// strokeWidth: 2.0, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// SizedBox(width: 12.w), |
|
|
|
// Text( |
|
|
|
// 'generating'.tr, // 生成中... |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 16.sp, |
|
|
|
// fontWeight: FontWeight.w600, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ], |
|
|
|
// ); |
|
|
|
// } |
|
|
|
|
|
|
|
// 构建重新生成按钮 |
|
|
|
Widget _buildRegenerateSummaryButton( |
|
|
|
String combinedSourceText, bool isDarkMode) { |
|
|
|
if (controller.summaryResult.value.isEmpty || |
|
|
|
controller.isGeneratingSummary.value) { |
|
|
|
return SizedBox.shrink(); |
|
|
|
} |
|
|
|
|
|
|
|
return Container( |
|
|
|
width: double.infinity, |
|
|
|
margin: EdgeInsets.only(bottom: 16.h), |
|
|
|
child: OutlinedButton( |
|
|
|
onPressed: () => _extractSummary(combinedSourceText), |
|
|
|
style: OutlinedButton.styleFrom( |
|
|
|
foregroundColor: isDarkMode ? AppColors.primary : Colors.blue, |
|
|
|
side: BorderSide(color: isDarkMode ? AppColors.primary : Colors.blue), |
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
), |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
'regenerate'.tr, // 重新生成 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
// Widget _buildRegenerateSummaryButton( |
|
|
|
// String combinedSourceText, bool isDarkMode) { |
|
|
|
// if (controller.summaryResult.value.isEmpty || |
|
|
|
// controller.isGeneratingSummary.value) { |
|
|
|
// return SizedBox.shrink(); |
|
|
|
// } |
|
|
|
|
|
|
|
// return Container( |
|
|
|
// width: double.infinity, |
|
|
|
// margin: EdgeInsets.only(bottom: 16.h), |
|
|
|
// child: OutlinedButton( |
|
|
|
// onPressed: () => _extractSummary(combinedSourceText), |
|
|
|
// style: OutlinedButton.styleFrom( |
|
|
|
// foregroundColor: isDarkMode ? AppColors.primary : Colors.blue, |
|
|
|
// side: BorderSide(color: isDarkMode ? AppColors.primary : Colors.blue), |
|
|
|
// padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
// shape: RoundedRectangleBorder( |
|
|
|
// borderRadius: BorderRadius.circular(16.r), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// child: Text( |
|
|
|
// 'regenerate'.tr, // 重新生成 |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 16.sp, |
|
|
|
// fontWeight: FontWeight.w600, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ); |
|
|
|
// } |
|
|
|
|
|
|
|
// 提取摘要方法 |
|
|
|
void _extractSummary(String text) async { |
|
|
|
final result = await controller.extractSummary(text); |
|
|
|
// void _extractSummary(String text) async { |
|
|
|
// final result = await controller.extractSummary(text); |
|
|
|
|
|
|
|
// 检查是否超时,如果超时则显示重试选项 |
|
|
|
if (result.contains('超时')) { |
|
|
|
_showTimeoutDialog(text); |
|
|
|
} |
|
|
|
} |
|
|
|
// // 检查是否超时,如果超时则显示重试选项 |
|
|
|
// if (result.contains('超时')) { |
|
|
|
// _showTimeoutDialog(text); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
// 显示超时对话框 |
|
|
|
void _showTimeoutDialog(String text) { |
|
|
|
Get.dialog( |
|
|
|
AlertDialog( |
|
|
|
title: Text( |
|
|
|
'requestTimeout'.tr, // 请求超时 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 18.sp, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
), |
|
|
|
), |
|
|
|
content: Text( |
|
|
|
'summaryTimeoutMessage'.tr, // 生成摘要请求超时,可能是网络问题或服务器繁忙。 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
), |
|
|
|
), |
|
|
|
actions: [ |
|
|
|
TextButton( |
|
|
|
onPressed: () => Get.back(), |
|
|
|
child: Text( |
|
|
|
'cancel'.tr, // 取消 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
color: Colors.grey[700], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
TextButton( |
|
|
|
onPressed: () { |
|
|
|
Get.back(); |
|
|
|
// 使用延长的超时时间重试 |
|
|
|
controller.retryExtractSummaryWithExtendedTimeout(text); |
|
|
|
}, |
|
|
|
child: Text( |
|
|
|
'retry'.tr, // 重试 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
color: Colors.blue, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
// void _showTimeoutDialog(String text) { |
|
|
|
// Get.dialog( |
|
|
|
// AlertDialog( |
|
|
|
// title: Text( |
|
|
|
// 'requestTimeout'.tr, // 请求超时 |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 18.sp, |
|
|
|
// fontWeight: FontWeight.bold, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// content: Text( |
|
|
|
// 'summaryTimeoutMessage'.tr, // 生成摘要请求超时,可能是网络问题或服务器繁忙。 |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 16.sp, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// actions: [ |
|
|
|
// TextButton( |
|
|
|
// onPressed: () => Get.back(), |
|
|
|
// child: Text( |
|
|
|
// 'cancel'.tr, // 取消 |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 16.sp, |
|
|
|
// color: Colors.grey[700], |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// TextButton( |
|
|
|
// onPressed: () { |
|
|
|
// Get.back(); |
|
|
|
// // 使用延长的超时时间重试 |
|
|
|
// controller.retryExtractSummaryWithExtendedTimeout(text); |
|
|
|
// }, |
|
|
|
// child: Text( |
|
|
|
// 'retry'.tr, // 重试 |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 16.sp, |
|
|
|
// color: Colors.blue, |
|
|
|
// fontWeight: FontWeight.bold, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ], |
|
|
|
// shape: RoundedRectangleBorder( |
|
|
|
// borderRadius: BorderRadius.circular(12.r), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ); |
|
|
|
// } |
|
|
|
|
|
|
|
// 显示删除单条记录确认对话框 |
|
|
|
void _showDeleteItemConfirmDialog(TranslationItem item) { |
|
|
|
@ -750,18 +750,18 @@ class TranslationDetailView extends GetView<TranslationDetailController> { |
|
|
|
'${'originalText'.tr}:\n$sourceText\n\n${'translatedText'.tr}:\n$translatedText'; // 原文:译文: |
|
|
|
} else { |
|
|
|
// 分享摘要 |
|
|
|
if (controller.summaryResult.value.isNotEmpty) { |
|
|
|
shareText = |
|
|
|
'${'sessionSummary'.tr}:\n${controller.summaryResult.value}'; // 会话摘要: |
|
|
|
} else { |
|
|
|
Get.snackbar( |
|
|
|
'cannotShare'.tr, // 无法分享 |
|
|
|
'generateSummaryFirst'.tr, // 请先生成摘要 |
|
|
|
snackPosition: SnackPosition.BOTTOM, |
|
|
|
duration: Duration(seconds: 2), |
|
|
|
); |
|
|
|
return; |
|
|
|
} |
|
|
|
// if (controller.summaryResult.value.isNotEmpty) { |
|
|
|
// shareText = |
|
|
|
// '${'sessionSummary'.tr}:\n${controller.summaryResult.value}'; // 会话摘要: |
|
|
|
// } else { |
|
|
|
// Get.snackbar( |
|
|
|
// 'cannotShare'.tr, // 无法分享 |
|
|
|
// 'generateSummaryFirst'.tr, // 请先生成摘要 |
|
|
|
// snackPosition: SnackPosition.BOTTOM, |
|
|
|
// duration: Duration(seconds: 2), |
|
|
|
// ); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
// 调用系统分享 |
|
|
|
|