diff --git a/lib/modules/agent/controllers/agent_controller.dart b/lib/modules/agent/controllers/agent_controller.dart index 617cd5258..4f5517277 100644 --- a/lib/modules/agent/controllers/agent_controller.dart +++ b/lib/modules/agent/controllers/agent_controller.dart @@ -13,15 +13,16 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:app_settings/app_settings.dart'; class Message { - final bool isUser; - final String text; - final DateTime timestamp; + final bool isUser; //标识信息是否来自用户还是AI + final String text; //信息文本内容 + final DateTime timestamp; // 消息时间戳 final bool isRecognizing; // 是否为语音识别中的临时消息 final bool hasImage; // 是否包含图片 final String? imagePath; // 图片路径 final Map? meta; //卡片数据 Message({ + // 构造函数 required this.isUser, required this.text, DateTime? timestamp, @@ -33,14 +34,14 @@ class Message { } class AgentController extends GetxController { - static AgentController get to => Get.find(); + static AgentController get to => Get.find(); //单例访问模式 final logger = Logger(); // 聊天消息列表 final messages = [].obs; - // 控制器 + // UI控制器 final TextEditingController textController = TextEditingController(); final ScrollController scrollController = ScrollController(); @@ -49,10 +50,10 @@ class AgentController extends GetxController { var isPlaying = false.obs; var currentUrl = "".obs; - // 状态标志 + // 各种状态标志 final isInitialized = false.obs; - final isListening = false.obs; - final isSpeaking = false.obs; + final isListening = false.obs; //是否正在语音识别 + final isSpeaking = false.obs; //是否正在播放tts final isProcessing = false.obs; // TTS启用状态 final isTtsEnabled = true.obs; @@ -61,7 +62,7 @@ class AgentController extends GetxController { final isImageProcessing = false.obs; // 输入模式控制 - final isTextInputMode = true.obs; + final isTextInputMode = true.obs; //文本输入模式vs语音输入模式 // 当前输入的文本内容 final currentText = ''.obs; @@ -86,15 +87,15 @@ class AgentController extends GetxController { @override void onInit() { super.onInit(); - _loadTtsPreference(); - _loadChatHistory(); - _subscribeToEvents(); + _loadTtsPreference(); //加载TTS偏好设置 + _loadChatHistory(); //加载聊天历史记录 + _subscribeToEvents(); //订阅代理服务事件 } @override void onClose() { - AgentService.stopConversation(); - AgentService.stopTts(); + AgentService.stopConversation(); // 停止当前会话 + AgentService.stopTts(); // 停止当前语音 textController.dispose(); scrollController.dispose(); _eventSubscription?.cancel(); @@ -179,7 +180,7 @@ class AgentController extends GetxController { void _addWelcomeMessage() { messages.add(Message( isUser: false, - text: '你好!我是DeepVoice AI助手,我能帮你:\n\n' + text: '你好!我是Emma,我能帮你:\n\n' '• 回答问题和提供信息\n' '• 实时语音翻译\n' '• 推荐音乐和播客\n' diff --git a/lib/modules/agent/views/agent_view.dart b/lib/modules/agent/views/agent_view.dart index f32a0caee..dd642fd4e 100644 --- a/lib/modules/agent/views/agent_view.dart +++ b/lib/modules/agent/views/agent_view.dart @@ -52,7 +52,7 @@ class AgentView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'DeepVoice AI', + 'Emma', style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, @@ -71,7 +71,7 @@ class AgentView extends StatelessWidget { ), const SizedBox(width: 4), Text( - '在线', + '在线'.tr, style: TextStyle( fontSize: 12, color: Colors.green, @@ -131,7 +131,7 @@ class AgentView extends StatelessWidget { children: [ Icon(Icons.delete_outline, color: primaryColor, size: 20), const SizedBox(width: 8), - const Text('清除聊天记录', style: TextStyle(fontSize: 14)), + Text('清除聊天记录'.tr, style: TextStyle(fontSize: 14)), ], ), onTap: () => Future.delayed( @@ -246,19 +246,19 @@ class AgentView extends StatelessWidget { children: [ _buildPromptChip( context: context, - label: '总结图片内容', + label: '总结图片内容'.tr, onTap: () => controller.summarizeImage(), ), const SizedBox(width: 8), _buildPromptChip( context: context, - label: '抽取图像文字', + label: '抽取图像文字'.tr, onTap: () => controller.extractTextFromImage(), ), const SizedBox(width: 8), _buildPromptChip( context: context, - label: '翻译图像文字', + label: '翻译图像文字'.tr, onTap: () => controller.translateImageText(), ), ], diff --git a/lib/modules/agent/views/message_bubble.dart b/lib/modules/agent/views/message_bubble.dart index eb0f9f201..8eeb04681 100644 --- a/lib/modules/agent/views/message_bubble.dart +++ b/lib/modules/agent/views/message_bubble.dart @@ -311,7 +311,7 @@ class MessageBubble extends GetView { ), const SizedBox(width: 6), Text( - '雨天时光 · 播放列表', + '播放列表'.tr, style: TextStyle( fontSize: 13, fontWeight: FontWeight.w600,