From 78db92847a7aabf0caa68e2b6fc4dc2245a66b8a Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Sat, 11 Oct 2025 12:12:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81=E8=A1=A5?= =?UTF-8?q?=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/modules/agent/views/message_bubble.dart | 84 ++++++++++--------- .../azure_speech/AzureSpeechPlugin.kt | 19 +++-- 2 files changed, 58 insertions(+), 45 deletions(-) diff --git a/lib/modules/agent/views/message_bubble.dart b/lib/modules/agent/views/message_bubble.dart index fed515b23..7feb47f07 100644 --- a/lib/modules/agent/views/message_bubble.dart +++ b/lib/modules/agent/views/message_bubble.dart @@ -56,34 +56,33 @@ class MessageBubble extends GetView { crossAxisAlignment: isUser ? CrossAxisAlignment.end : CrossAxisAlignment.start, children: [ - Container( - padding: (hasImage && message == '[图片]') - ? EdgeInsets.zero - : const EdgeInsets.all(12), - decoration: BoxDecoration( - color: _getBubbleColor(context), - borderRadius: BorderRadius.only( - topLeft: isUser - ? const Radius.circular(18) - : const Radius.circular(4), - topRight: isUser - ? const Radius.circular(4) - : const Radius.circular(18), - bottomLeft: const Radius.circular(18), - bottomRight: const Radius.circular(18), - ), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.05), - blurRadius: 2, - offset: const Offset(0, 1), + Stack( + children: [ + Container( + padding: (hasImage && message == '[图片]') + ? EdgeInsets.zero + : const EdgeInsets.all(12), + decoration: BoxDecoration( + color: _getBubbleColor(context), + borderRadius: BorderRadius.only( + topLeft: isUser + ? const Radius.circular(18) + : const Radius.circular(4), + topRight: isUser + ? const Radius.circular(4) + : const Radius.circular(18), + bottomLeft: const Radius.circular(18), + bottomRight: const Radius.circular(18), + ), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.05), + blurRadius: 2, + offset: const Offset(0, 1), + ), + ], ), - ], - ), - child: Stack( - children: [ - // 主要消息内容 - Padding( + child: Padding( padding: (!isUser && functionCalls != null && functionCalls!.isNotEmpty) @@ -91,14 +90,15 @@ class MessageBubble extends GetView { : EdgeInsets.zero, child: _buildMessageContent(context), ), - //工具调用流程显示(仅在AI消息且有functionCalls时显示) - if (!isUser && - functionCalls != null && - functionCalls!.isNotEmpty) - _buildFunctionCallsWidget(context), - ], - ), + ), + //工具调用流程显示(仅在AI消息且有functionCalls时显示) + if (!isUser && + functionCalls != null && + functionCalls!.isNotEmpty) + _buildFunctionCallsWidget(context), + ], ), + const SizedBox(height: 4), // 识别中的消息不显示时间 if (!isRecognizing) @@ -621,12 +621,17 @@ class MessageBubble extends GetView { ); }, child: Container( - height: 20, // 增加固定高度,给字体更多空间 + height: 30, // 增加固定高度,给字体更多空间 + padding: EdgeInsets.all(8), decoration: BoxDecoration( color: Theme.of(context).brightness == Brightness.dark - ? Colors.grey[800]?.withOpacity(0.8) + ? const Color.fromARGB(255, 71, 68, 68) + ?.withOpacity(0.8) : Colors.grey[100]?.withOpacity(0.9), - borderRadius: BorderRadius.circular(6), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(6), + topRight: Radius.circular(6), + ), border: Border.all( color: Theme.of(context).brightness == Brightness.dark ? Colors.white.withOpacity(0.1) @@ -682,7 +687,10 @@ class MessageBubble extends GetView { color: Theme.of(context).brightness == Brightness.dark ? Colors.grey[900]?.withOpacity(0.95) // 深色模式下使用深灰色背景 : Colors.white.withOpacity(0.95), // 浅色模式下使用白色背景 - borderRadius: BorderRadius.circular(4), // 减小圆角 + borderRadius: const BorderRadius.only( + bottomLeft: Radius.circular(6), + bottomRight: Radius.circular(6), + ), border: Border.all( color: Theme.of(context).brightness == Brightness.dark ? Colors.white.withOpacity(0.2) diff --git a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt index 6348732c2..80525d56d 100644 --- a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt +++ b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt @@ -209,11 +209,12 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin { try { azureAsrHelper.setupEventListeners(object : AzureAsrHelper.ContinuousRecognizeCallback { - override fun onResult(text: String, detectedLanguage: String) { + override fun onResult(sessionid:String,text: String, detectedLanguage: String) { sendAsrEvent( mapOf( "type" to "result", + "sessionid" to sessionid, "text" to text, "detectedLanguage" to detectedLanguage ) @@ -222,6 +223,7 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin { } override fun onRecognizing( + sessionid:String, recognizing: String, detectedLanguage: String ) { @@ -229,26 +231,28 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin { sendAsrEvent( mapOf( "type" to "recognizing", + "sessionid" to sessionid, "text" to recognizing, "detectedLanguage" to detectedLanguage ) ) } - override fun onSessionStarted() { - sendAsrEvent(mapOf("type" to "sessionStarted")) + override fun onSessionStarted(sessionid:String) { + sendAsrEvent(mapOf("type" to "sessionStarted","sessionid" to sessionid,)) } - override fun onSessionStopped() { - sendAsrEvent(mapOf("type" to "sessionStopped")) + override fun onSessionStopped(sessionid:String) { + sendAsrEvent(mapOf("type" to "sessionStopped","sessionid" to sessionid,)) } - override fun onCanceled(reason: String, errorDetails: String) { + override fun onCanceled(sessionid:String,reason: String, errorDetails: String) { sendAsrEvent( mapOf( "type" to "canceled", + "sessionid" to sessionid, "reason" to reason, "errorDetails" to errorDetails ) @@ -257,10 +261,11 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin { } - override fun onError(code: Int, error: String) { + override fun onError(sessionid:String,code: Int, error: String) { sendAsrEvent( mapOf( "type" to "error", + "sessionid" to sessionid, "code" to code, "message" to error )