From ae8586bc4a6840456b10a8f8dfdc39465e5d32d9 Mon Sep 17 00:00:00 2001 From: qinglong Date: Sat, 13 Jun 2026 12:00:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=20Static=20=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E6=A0=8F=E6=9B=BF=E4=BB=A3=20Textual=20Header=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E5=A7=8B=E7=BB=88=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 自定义 #title-bar (dock top, height 1, bold) - 移除不可靠的 Header widget - _setup_title 更新 title_bar 内容 Co-Authored-By: Claude --- services/tui_service.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/services/tui_service.py b/services/tui_service.py index c488223..f434d10 100644 --- a/services/tui_service.py +++ b/services/tui_service.py @@ -7,7 +7,7 @@ import io import time from textual.app import App from textual.containers import Container, ScrollableContainer -from textual.widgets import Static, Input, Header +from textual.widgets import Static, Input from textual.suggester import Suggester try: @@ -546,6 +546,7 @@ class TUIFramework(App): self.message_display = MessageDisplay() self.system_monitor = SystemMonitor() self.plugin_panel = PluginStatusPanel(plugin_service) + self.title_bar = Static("🐱 SenSu", id="title-bar") self.command_input = None self.CSS = self._generate_css() @@ -553,8 +554,13 @@ class TUIFramework(App): def _generate_css(self): """动态生成 CSS — dock 布局:标题 + 状态栏 + 主内容 + 底部输入""" return """ - Header { + #title-bar { dock: top; + height: 1; + padding: 0 1; + background: $panel; + color: $text; + text-style: bold; } #monitor-area { @@ -591,7 +597,7 @@ class TUIFramework(App): def compose(self): """组合界面 — 标题 + 状态栏 / 主显示区 / 底部输入栏""" - yield Header() + yield self.title_bar yield Container( self.system_monitor, self.plugin_panel, @@ -851,20 +857,15 @@ class TuiService: name = framework_config.get('name', 'SenSu') version = framework_config.get('version', 'Unknown') debug_mode = framework_config.get('debug', False) - - # 构建标题 - title_parts = [f"🐱 {name} Ver.{version}"] + + title = f"🐱 {name} Ver.{version}" if debug_mode: - title_parts.append("[DEBUG]") - - self.tui_app.title = " ".join(title_parts) - self.tui_app.sub_title = "Based DreamSu Framework" - logger.debug(f"设置TUI标题: {self.tui_app.title}") - logger.debug(f"设置TUI副标题: {self.tui_app.sub_title}") - + title += " [DEBUG]" + self.tui_app.title_bar.update(title) + logger.debug(f"设置TUI标题: {title}") + except Exception as e: - logger.error(f"设置TUI标题时出错: {e}") - self.tui_app.title = "🐱 SenSu - Based DreamSu Framework" # 默认标题 + logger.error(f"设置TUI标题时出错: {e}") async def _run_tui(self): """运行TUI"""