From bb6812643f2ece54869f52c94675332fbc7f3315 Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Sat, 7 Jun 2025 11:17:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor(agent):=20-=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3=E6=98=BE=E7=A4=BA=E4=B8=BA=E8=A1=8C?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E5=B9=B6=E6=B7=BB=E5=8A=A0AI=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/modules/agent/views/message_bubble.dart | 104 ++++++-------------- 1 file changed, 32 insertions(+), 72 deletions(-) diff --git a/lib/modules/agent/views/message_bubble.dart b/lib/modules/agent/views/message_bubble.dart index b4a7a0ed4..6cc443704 100644 --- a/lib/modules/agent/views/message_bubble.dart +++ b/lib/modules/agent/views/message_bubble.dart @@ -46,8 +46,6 @@ class MessageBubble extends GetView { isUser ? MainAxisAlignment.end : MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - //if (!isUser) _buildAvatar(isUser, context), - //const SizedBox(width: 8), Flexible( child: Column( crossAxisAlignment: @@ -90,21 +88,42 @@ class MessageBubble extends GetView { const SizedBox(height: 4), // 识别中的消息不显示时间 if (!isRecognizing) - Text( - timeFormat.format(timestamp), - style: TextStyle( - fontSize: 10, - color: Theme.of(context).brightness == Brightness.dark - ? Colors.grey[400] - : Colors.grey[500], - fontWeight: FontWeight.w400, - ), + Row( + mainAxisAlignment: isUser + ? MainAxisAlignment.end + : MainAxisAlignment.start, + children: [ + // 时间戳(左对齐或右对齐) + Text( + timeFormat.format(timestamp), + style: TextStyle( + fontSize: 10, + color: Theme.of(context).brightness == Brightness.dark + ? Colors.grey[400] + : Colors.grey[500], + fontWeight: FontWeight.w400, + ), + ), + const Spacer(), + // AI标识(仅在AI消息时显示) + if (!isUser) + Padding( + padding: const EdgeInsets.only(left: 8), + child: Text( + "由AI生成".tr, + style: TextStyle( + fontSize: 8, + color: Colors.blue[600], + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic, + ), + ), + ), + ], ), ], ), ), - //const SizedBox(width: 8), - //if (isUser) _buildAvatar(isUser, context), ], ), ); @@ -125,65 +144,6 @@ class MessageBubble extends GetView { } } - /// 构建头像 - // Widget _buildAvatar(bool isUser, BuildContext context) { - // if (isUser) { - // final storage = GetStorage(); - // final localAvatarPath = storage.read('local_avatar') ?? ''; - - // return Container( - // width: 36, - // height: 36, - // decoration: BoxDecoration( - // color: localAvatarPath.isEmpty ? Colors.grey[300] : null, - // borderRadius: BorderRadius.circular(18), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withOpacity(0.05), - // blurRadius: 2, - // offset: const Offset(0, 1), - // ), - // ], - // ), - // child: localAvatarPath.isNotEmpty - // ? ClipRRect( - // borderRadius: BorderRadius.circular(18), - // child: Image.file( - // File(localAvatarPath), - // fit: BoxFit.cover, - // ), - // ) - // : Icon( - // Icons.person, - // color: Colors.grey[700], - // size: 20, - // ), - // ); - // } else { - // // AI头像保持不变 - // return Container( - // width: 36, - // height: 36, - // decoration: BoxDecoration( - // color: Theme.of(context).primaryColor, - // borderRadius: BorderRadius.circular(18), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withOpacity(0.05), - // blurRadius: 2, - // offset: const Offset(0, 1), - // ), - // ], - // ), - // child: Icon( - // Icons.smart_toy_outlined, - // color: Colors.white, - // size: 20, - // ), - // ); - // } - // } - /// 构建消息内容 Widget _buildMessageContent(BuildContext context) { // 如果是识别中的消息,添加特殊样式