From 0ee396f8faccd06c813d8bdd799d697f7230e9db Mon Sep 17 00:00:00 2001 From: JianFeeeee <109188060+JianFeeeee@users.noreply.github.com> Date: Wed, 15 Apr 2026 08:12:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=B9=E8=BF=9B=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E6=94=AF=E6=8C=81=E5=A4=9A=E8=A1=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E5=92=8C=E5=8F=91=E9=80=81=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 将Input组件替换为TextArea,支持多行文本输入和粘贴 2. 添加发送按钮,点击即可发送消息 3. Enter键用于换行,支持多行编辑 4. 在帮助信息中显示配置文件和数据库路径 5. 优化输入框样式和布局 🤖 Generated with CodeArts Agent --- ui/app.py | 11 ++++++++++- ui/styles/components.css | 12 +++++++++++- ui/widgets/input_box.py | 38 ++++++++++++++++++++++++++------------ 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/ui/app.py b/ui/app.py index c9094f3..e8e0691 100644 --- a/ui/app.py +++ b/ui/app.py @@ -86,7 +86,16 @@ class GraphMemoryApp(App): self._backend_client.shutdown() def action_show_help(self) -> None: - self.notify("F1-帮助 F2-侧边栏 F3-工具详情 F5-清屏 F6-退出", title="快捷键", timeout=10) + from pathlib import Path + config_path = Path.home() / ".trulymem" / "config.json" + db_path = Path.home() / ".trulymem" / "graph_memory.db" + + help_text = ( + "F1-帮助 F2-侧边栏 F3-工具详情 F5-清屏 F6-退出\n\n" + f"配置文件: {config_path}\n" + f"数据库: {db_path}" + ) + self.notify(help_text, title="快捷键 & 配置路径", timeout=15) def action_toggle_sidebar(self) -> None: from .widgets.right_panel import RightPanel diff --git a/ui/styles/components.css b/ui/styles/components.css index cf2bcd0..d8fd197 100644 --- a/ui/styles/components.css +++ b/ui/styles/components.css @@ -8,13 +8,23 @@ InputBox { border: solid $primary; } -InputBox Input { +InputBox TextArea { width: 100%; + height: 5; background: $surface-lighten-1; color: $text; border: none; } +InputBox .input-buttons { + height: auto; + margin-top: 1; +} + +InputBox Button { + margin: 0; +} + /* Config Section */ ConfigSection { background: $surface; diff --git a/ui/widgets/input_box.py b/ui/widgets/input_box.py index 47a8904..47b2a7a 100644 --- a/ui/widgets/input_box.py +++ b/ui/widgets/input_box.py @@ -1,7 +1,7 @@ """输入框组件""" -from textual.containers import Container -from textual.widgets import Input +from textual.containers import Container, Horizontal +from textual.widgets import TextArea, Button from textual.message import Message @@ -21,20 +21,34 @@ class InputBox(Container): def compose(self): """构建输入框""" - yield Input( - placeholder="输入消息... (Enter发送)", + yield TextArea( + placeholder="输入消息... (Enter换行)", id="input-textarea" ) + with Horizontal(classes="input-buttons"): + yield Button("发送", id="send-button", variant="primary") def on_mount(self) -> None: """组件挂载时""" # 设置焦点 - input_widget = self.query_one(Input) - input_widget.focus() + textarea = self.query_one(TextArea) + textarea.focus() - def on_input_submitted(self, event: Input.Submitted) -> None: - """处理输入提交事件""" - content = event.value.strip() + def on_button_pressed(self, event: Button.Pressed) -> None: + """处理按钮点击""" + if event.button.id == "send-button": + self._send_message() + + def on_key(self, event) -> None: + """处理按键事件""" + if event.key == "enter" and event.ctrl: + self._send_message() + event.stop() + + def _send_message(self) -> None: + """发送消息""" + textarea = self.query_one(TextArea) + content = textarea.text.strip() if content: # 保存到历史 self._history.append(content) @@ -42,9 +56,9 @@ class InputBox(Container): # 发送消息 self.post_message(self.SendMessage(content)) # 清空输入框 - event.input.value = "" + textarea.clear() def focus(self) -> None: """聚焦输入框""" - input_widget = self.query_one(Input) - input_widget.focus() + textarea = self.query_one(TextArea) + textarea.focus()