From 0f9001beefa2582d654e5f70d7cf6343951b6d24 Mon Sep 17 00:00:00 2001 From: JianFeeeee <109188060+JianFeeeee@users.noreply.github.com> Date: Wed, 29 Apr 2026 23:24:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20TUI=20=E4=BE=A7?= =?UTF-8?q?=E8=BE=B9=E6=A0=8F=E9=85=8D=E7=BD=AE=E5=B8=83=E5=B1=80=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=92=8C=E6=89=93=E5=8C=85=E5=9B=BE=E6=A0=87=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. TUI 配置面板布局修复: 移除嵌套 Vertical 容器, 统一使用 admin-section 类 2. 打包脚本修复: 修正 trulymem.spec 中图标路径为绝对路径 3. 代码清理: 移除 embedded_db.py 末尾的测试代码 Generated with CodeArts Agent --- build/trulymem.spec | 2 +- core/embedded_db.py | 26 ------ core/web_api.py | 1 - ui/styles/components.css | 11 ++- ui/widgets/config_section.py | 154 +++++++++++++++++------------------ 5 files changed, 81 insertions(+), 113 deletions(-) diff --git a/build/trulymem.spec b/build/trulymem.spec index 39c10bd..1336527 100644 --- a/build/trulymem.spec +++ b/build/trulymem.spec @@ -83,7 +83,7 @@ exe = EXE( a.datas, [], name='TrulyMEM', - icon='pic/TrulyMEM.ico', + icon=os.path.join(project_root, 'pic', 'TrulyMEM.ico'), debug=False, bootloader_ignore_signals=False, strip=False, diff --git a/core/embedded_db.py b/core/embedded_db.py index a36c2b5..a6fea78 100644 --- a/core/embedded_db.py +++ b/core/embedded_db.py @@ -768,29 +768,3 @@ class EmbeddedGraphDB: # 兼容性别名 Neo4jGraph = EmbeddedGraphDB - -if __name__ == '__main__': - # 测试 - print("Testing Embedded Graph Database...") - - with EmbeddedGraphDB("test.db") as db: - # 写入测试 - result = db.commit( - triplets=[ - {"subject": "用户", "relation": "喜欢", "object": "Python"}, - {"subject": "用户", "relation": "学习", "object": "AI"} - ], - session_id="test-session", - turn_id=1 - ) - print(f"Commit: {result}") - - # 检索测试 - result = db.recall("Python,AI") - print(f"Recall: {result}") - - # 状态测试 - result = db.introspect() - print(f"Introspect: {result}") - - print("\nTest completed!") diff --git a/core/web_api.py b/core/web_api.py index a716d4d..f55b65b 100644 --- a/core/web_api.py +++ b/core/web_api.py @@ -784,7 +784,6 @@ def get_graph(): SELECT id, name, type, mention_count FROM entities ORDER BY mention_count DESC - LIMIT 200 """) nodes = [] diff --git a/ui/styles/components.css b/ui/styles/components.css index 6500420..f53e52f 100644 --- a/ui/styles/components.css +++ b/ui/styles/components.css @@ -51,6 +51,11 @@ ConfigSection .config-hint { margin: 1 0 0 0; } +ConfigSection .config-sep { + height: 1; + margin: 1 0; +} + ConfigSection Input { width: 1fr; height: 3; @@ -65,10 +70,8 @@ ConfigSection Checkbox { margin: 1 0; } -/* Admin sections */ -#admin-web-login-section, -#admin-web-service-section, -#admin-tui-service-section { +/* Admin section elements - controlled by visibility */ +ConfigSection .admin-section { display: block; } diff --git a/ui/widgets/config_section.py b/ui/widgets/config_section.py index f9616dc..5f9b571 100644 --- a/ui/widgets/config_section.py +++ b/ui/widgets/config_section.py @@ -89,83 +89,87 @@ class ConfigSection(Vertical): yield sep2 # Web 登录 — 仅 admin 可见 - with Vertical(id="admin-web-login-section"): - web_title = Static("━━ Web 登录 ━━", classes="config-title") - web_title.can_focus = False - yield web_title - - label_web_user = Static("用户名:", classes="config-label") - label_web_user.can_focus = False - yield label_web_user - yield Input( - value=self._config.web_username, - placeholder="admin", - id="web-username-input" - ) - - label_web_pwd = Static("密码:", classes="config-label") - label_web_pwd.can_focus = False - yield label_web_pwd - yield Input( - value=self._config.web_password, - placeholder="修改密码", - id="web-password-input", - password=True - ) - - hint = Static("按Enter保存配置", classes="config-hint") - hint.can_focus = False - yield hint + web_title = Static("━━ Web 登录 ━━", classes="config-title admin-section") + web_title.can_focus = False + yield web_title + + label_web_user = Static("用户名:", classes="config-label admin-section") + label_web_user.can_focus = False + yield label_web_user + yield Input( + value=self._config.web_username, + placeholder="admin", + id="web-username-input", + classes="admin-section" + ) + + label_web_pwd = Static("密码:", classes="config-label admin-section") + label_web_pwd.can_focus = False + yield label_web_pwd + yield Input( + value=self._config.web_password, + placeholder="修改密码", + id="web-password-input", + password=True, + classes="admin-section" + ) + + hint = Static("按Enter保存配置", classes="config-hint admin-section") + hint.can_focus = False + yield hint - sep3 = Static("", classes="config-sep") - sep3.can_focus = False - yield sep3 + sep3 = Static("", classes="config-sep admin-section") + sep3.can_focus = False + yield sep3 # Web 服务 — 仅 admin 可见 - with Vertical(id="admin-web-service-section"): - ws_title = Static("━━ Web 服务 ━━", classes="config-title") - ws_title.can_focus = False - yield ws_title + ws_title = Static("━━ Web 服务 ━━", classes="config-title admin-section") + ws_title.can_focus = False + yield ws_title - ws_hint = Static("在侧边栏启用后将自动启动 Web 管理界面", classes="config-hint") - ws_hint.can_focus = False - yield ws_hint + ws_hint = Static("在侧边栏启用后将自动启动 Web 管理界面", classes="config-hint admin-section") + ws_hint.can_focus = False + yield ws_hint - yield Checkbox( - "启用 Web 服务", - value=self._config.enable_web, - id="enable-web-checkbox" - ) + cb_web = Checkbox( + "启用 Web 服务", + value=self._config.enable_web, + id="enable-web-checkbox", + classes="admin-section" + ) + yield cb_web - label_web_port = Static("端口:", classes="config-label") - label_web_port.can_focus = False - yield label_web_port - yield Input( - value=str(self._config.web_port), - placeholder="4096", - id="web-port-input", - type="integer" - ) + label_web_port = Static("端口:", classes="config-label admin-section") + label_web_port.can_focus = False + yield label_web_port + yield Input( + value=str(self._config.web_port), + placeholder="4096", + id="web-port-input", + type="integer", + classes="admin-section" + ) - sep4 = Static("", classes="config-sep") - sep4.can_focus = False - yield sep4 + sep4 = Static("", classes="config-sep admin-section") + sep4.can_focus = False + yield sep4 # TUI 服务控制 — 仅 admin 可见 - with Vertical(id="admin-tui-service-section"): - tui_title = Static("━━ TUI 服务 ━━", classes="config-title") - tui_title.can_focus = False - yield tui_title + tui_title = Static("━━ TUI 服务 ━━", classes="config-title admin-section") + tui_title.can_focus = False + yield tui_title - tui_hint = Static("控制终端文本界面是否允许连接", classes="config-hint") - tui_hint.can_focus = False - yield tui_hint + tui_hint = Static("控制终端文本界面是否允许连接", classes="config-hint admin-section") + tui_hint.can_focus = False + yield tui_hint - yield Checkbox( - "启用 TUI 服务", - value=self._config.enable_tui, - id="enable-tui-checkbox" - ) + cb_tui = Checkbox( + "启用 TUI 服务", + value=self._config.enable_tui, + id="enable-tui-checkbox", + classes="admin-section" + ) + yield cb_tui def on_mount(self) -> None: # 应用管理员区域的可见性 @@ -274,21 +278,9 @@ class ConfigSection(Vertical): def _apply_admin_visibility(self) -> None: """根据 _is_admin 显示/隐藏 admin 专用区域""" - try: - login_section = self.query_one("#admin-web-login-section") - login_section.styles.display = "block" if self._is_admin else "none" - except Exception: - pass - try: - service_section = self.query_one("#admin-web-service-section") - service_section.styles.display = "block" if self._is_admin else "none" - except Exception: - pass - try: - tui_section = self.query_one("#admin-tui-service-section") - tui_section.styles.display = "block" if self._is_admin else "none" - except Exception: - pass + display_val = "block" if self._is_admin else "none" + for widget in self.query(".admin-section"): + widget.styles.display = display_val def get_config(self) -> AppConfig: return self._config