From fdfb5ad954ab4ba6483a64fd7d23f3098324883f Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Thu, 12 Jun 2025 19:54:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(agent):=20=E4=BC=98=E5=8C=96=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=8F=91=E9=80=81=E6=97=B6=E7=9A=84=E9=94=AE=E7=9B=98?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E5=92=8C=E8=BE=93=E5=85=A5=E6=A1=86=E5=A4=9A?= =?UTF-8?q?=E8=A1=8C=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在发送消息时自动收回键盘 - 修改输入框配置以支持多行输入和换行 - 启用多行键盘类型和换行操作 --- lib/modules/agent/controllers/agent_controller.dart | 2 ++ lib/modules/agent/views/agent_view.dart | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/modules/agent/controllers/agent_controller.dart b/lib/modules/agent/controllers/agent_controller.dart index f1a51375c..792556053 100644 --- a/lib/modules/agent/controllers/agent_controller.dart +++ b/lib/modules/agent/controllers/agent_controller.dart @@ -502,6 +502,8 @@ class AgentController extends GetxController { //场景1:用户在文本输入框中输入文本,点击发送按钮,调用sendMessage()方法。 //场景2:当用户选择图片后在文本框输入内容并发送时,调用sendMessage()转发给sendImageMessage()。 Future sendMessage() async { + // 收回键盘 + FocusManager.instance.primaryFocus?.unfocus(); // 1. 处理图片+文本的混合输入 if (isImageInputActive.value && selectedImagePath.value != null) { final text = textController.text.trim(); diff --git a/lib/modules/agent/views/agent_view.dart b/lib/modules/agent/views/agent_view.dart index 6ba38309e..7d291e622 100644 --- a/lib/modules/agent/views/agent_view.dart +++ b/lib/modules/agent/views/agent_view.dart @@ -364,8 +364,12 @@ class AgentView extends StatelessWidget { return TextField( controller: controller.textController, - maxLines: isImageActive ? 2 : 1, + maxLines: isImageActive ? 2 : null, minLines: isImageActive ? 2 : 1, + keyboardType: + TextInputType.multiline, // 启用多行键盘 + textInputAction: + TextInputAction.newline, // 支持回车换行 style: TextStyle( fontSize: 15, color: isDarkMode