fix: 修复 TUI 侧边栏配置布局问题和打包图标路径
1. TUI 配置面板布局修复: 移除嵌套 Vertical 容器, 统一使用 admin-section 类 2. 打包脚本修复: 修正 trulymem.spec 中图标路径为绝对路径 3. 代码清理: 移除 embedded_db.py 末尾的测试代码 Generated with CodeArts Agent
This commit is contained in:
@ -83,7 +83,7 @@ exe = EXE(
|
|||||||
a.datas,
|
a.datas,
|
||||||
[],
|
[],
|
||||||
name='TrulyMEM',
|
name='TrulyMEM',
|
||||||
icon='pic/TrulyMEM.ico',
|
icon=os.path.join(project_root, 'pic', 'TrulyMEM.ico'),
|
||||||
debug=False,
|
debug=False,
|
||||||
bootloader_ignore_signals=False,
|
bootloader_ignore_signals=False,
|
||||||
strip=False,
|
strip=False,
|
||||||
|
|||||||
@ -768,29 +768,3 @@ class EmbeddedGraphDB:
|
|||||||
# 兼容性别名
|
# 兼容性别名
|
||||||
Neo4jGraph = 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!")
|
|
||||||
|
|||||||
@ -784,7 +784,6 @@ def get_graph():
|
|||||||
SELECT id, name, type, mention_count
|
SELECT id, name, type, mention_count
|
||||||
FROM entities
|
FROM entities
|
||||||
ORDER BY mention_count DESC
|
ORDER BY mention_count DESC
|
||||||
LIMIT 200
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
nodes = []
|
nodes = []
|
||||||
|
|||||||
@ -51,6 +51,11 @@ ConfigSection .config-hint {
|
|||||||
margin: 1 0 0 0;
|
margin: 1 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigSection .config-sep {
|
||||||
|
height: 1;
|
||||||
|
margin: 1 0;
|
||||||
|
}
|
||||||
|
|
||||||
ConfigSection Input {
|
ConfigSection Input {
|
||||||
width: 1fr;
|
width: 1fr;
|
||||||
height: 3;
|
height: 3;
|
||||||
@ -65,10 +70,8 @@ ConfigSection Checkbox {
|
|||||||
margin: 1 0;
|
margin: 1 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin sections */
|
/* Admin section elements - controlled by visibility */
|
||||||
#admin-web-login-section,
|
ConfigSection .admin-section {
|
||||||
#admin-web-service-section,
|
|
||||||
#admin-tui-service-section {
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -89,83 +89,87 @@ class ConfigSection(Vertical):
|
|||||||
yield sep2
|
yield sep2
|
||||||
|
|
||||||
# Web 登录 — 仅 admin 可见
|
# Web 登录 — 仅 admin 可见
|
||||||
with Vertical(id="admin-web-login-section"):
|
web_title = Static("━━ Web 登录 ━━", classes="config-title admin-section")
|
||||||
web_title = Static("━━ Web 登录 ━━", classes="config-title")
|
web_title.can_focus = False
|
||||||
web_title.can_focus = False
|
yield web_title
|
||||||
yield web_title
|
|
||||||
|
label_web_user = Static("用户名:", classes="config-label admin-section")
|
||||||
label_web_user = Static("用户名:", classes="config-label")
|
label_web_user.can_focus = False
|
||||||
label_web_user.can_focus = False
|
yield label_web_user
|
||||||
yield label_web_user
|
yield Input(
|
||||||
yield Input(
|
value=self._config.web_username,
|
||||||
value=self._config.web_username,
|
placeholder="admin",
|
||||||
placeholder="admin",
|
id="web-username-input",
|
||||||
id="web-username-input"
|
classes="admin-section"
|
||||||
)
|
)
|
||||||
|
|
||||||
label_web_pwd = Static("密码:", classes="config-label")
|
label_web_pwd = Static("密码:", classes="config-label admin-section")
|
||||||
label_web_pwd.can_focus = False
|
label_web_pwd.can_focus = False
|
||||||
yield label_web_pwd
|
yield label_web_pwd
|
||||||
yield Input(
|
yield Input(
|
||||||
value=self._config.web_password,
|
value=self._config.web_password,
|
||||||
placeholder="修改密码",
|
placeholder="修改密码",
|
||||||
id="web-password-input",
|
id="web-password-input",
|
||||||
password=True
|
password=True,
|
||||||
)
|
classes="admin-section"
|
||||||
|
)
|
||||||
hint = Static("按Enter保存配置", classes="config-hint")
|
|
||||||
hint.can_focus = False
|
hint = Static("按Enter保存配置", classes="config-hint admin-section")
|
||||||
yield hint
|
hint.can_focus = False
|
||||||
|
yield hint
|
||||||
|
|
||||||
sep3 = Static("", classes="config-sep")
|
sep3 = Static("", classes="config-sep admin-section")
|
||||||
sep3.can_focus = False
|
sep3.can_focus = False
|
||||||
yield sep3
|
yield sep3
|
||||||
|
|
||||||
# Web 服务 — 仅 admin 可见
|
# Web 服务 — 仅 admin 可见
|
||||||
with Vertical(id="admin-web-service-section"):
|
ws_title = Static("━━ Web 服务 ━━", classes="config-title admin-section")
|
||||||
ws_title = Static("━━ Web 服务 ━━", classes="config-title")
|
ws_title.can_focus = False
|
||||||
ws_title.can_focus = False
|
yield ws_title
|
||||||
yield ws_title
|
|
||||||
|
|
||||||
ws_hint = Static("在侧边栏启用后将自动启动 Web 管理界面", classes="config-hint")
|
ws_hint = Static("在侧边栏启用后将自动启动 Web 管理界面", classes="config-hint admin-section")
|
||||||
ws_hint.can_focus = False
|
ws_hint.can_focus = False
|
||||||
yield ws_hint
|
yield ws_hint
|
||||||
|
|
||||||
yield Checkbox(
|
cb_web = Checkbox(
|
||||||
"启用 Web 服务",
|
"启用 Web 服务",
|
||||||
value=self._config.enable_web,
|
value=self._config.enable_web,
|
||||||
id="enable-web-checkbox"
|
id="enable-web-checkbox",
|
||||||
)
|
classes="admin-section"
|
||||||
|
)
|
||||||
|
yield cb_web
|
||||||
|
|
||||||
label_web_port = Static("端口:", classes="config-label")
|
label_web_port = Static("端口:", classes="config-label admin-section")
|
||||||
label_web_port.can_focus = False
|
label_web_port.can_focus = False
|
||||||
yield label_web_port
|
yield label_web_port
|
||||||
yield Input(
|
yield Input(
|
||||||
value=str(self._config.web_port),
|
value=str(self._config.web_port),
|
||||||
placeholder="4096",
|
placeholder="4096",
|
||||||
id="web-port-input",
|
id="web-port-input",
|
||||||
type="integer"
|
type="integer",
|
||||||
)
|
classes="admin-section"
|
||||||
|
)
|
||||||
|
|
||||||
sep4 = Static("", classes="config-sep")
|
sep4 = Static("", classes="config-sep admin-section")
|
||||||
sep4.can_focus = False
|
sep4.can_focus = False
|
||||||
yield sep4
|
yield sep4
|
||||||
|
|
||||||
# TUI 服务控制 — 仅 admin 可见
|
# TUI 服务控制 — 仅 admin 可见
|
||||||
with Vertical(id="admin-tui-service-section"):
|
tui_title = Static("━━ TUI 服务 ━━", classes="config-title admin-section")
|
||||||
tui_title = Static("━━ TUI 服务 ━━", classes="config-title")
|
tui_title.can_focus = False
|
||||||
tui_title.can_focus = False
|
yield tui_title
|
||||||
yield tui_title
|
|
||||||
|
|
||||||
tui_hint = Static("控制终端文本界面是否允许连接", classes="config-hint")
|
tui_hint = Static("控制终端文本界面是否允许连接", classes="config-hint admin-section")
|
||||||
tui_hint.can_focus = False
|
tui_hint.can_focus = False
|
||||||
yield tui_hint
|
yield tui_hint
|
||||||
|
|
||||||
yield Checkbox(
|
cb_tui = Checkbox(
|
||||||
"启用 TUI 服务",
|
"启用 TUI 服务",
|
||||||
value=self._config.enable_tui,
|
value=self._config.enable_tui,
|
||||||
id="enable-tui-checkbox"
|
id="enable-tui-checkbox",
|
||||||
)
|
classes="admin-section"
|
||||||
|
)
|
||||||
|
yield cb_tui
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
# 应用管理员区域的可见性
|
# 应用管理员区域的可见性
|
||||||
@ -274,21 +278,9 @@ class ConfigSection(Vertical):
|
|||||||
|
|
||||||
def _apply_admin_visibility(self) -> None:
|
def _apply_admin_visibility(self) -> None:
|
||||||
"""根据 _is_admin 显示/隐藏 admin 专用区域"""
|
"""根据 _is_admin 显示/隐藏 admin 专用区域"""
|
||||||
try:
|
display_val = "block" if self._is_admin else "none"
|
||||||
login_section = self.query_one("#admin-web-login-section")
|
for widget in self.query(".admin-section"):
|
||||||
login_section.styles.display = "block" if self._is_admin else "none"
|
widget.styles.display = display_val
|
||||||
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
|
|
||||||
|
|
||||||
def get_config(self) -> AppConfig:
|
def get_config(self) -> AppConfig:
|
||||||
return self._config
|
return self._config
|
||||||
|
|||||||
Reference in New Issue
Block a user