mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-10-15 12:15:32 +00:00
fix: on_login_success 使用 call_after_refresh 确保 DOM 就绪 + 去掉静默吞异常
This commit is contained in:
16
ui/app.py
16
ui/app.py
@ -91,15 +91,19 @@ class GraphMemoryApp(App):
|
||||
|
||||
# 更新 config section 的 admin 权限
|
||||
from .widgets.config_section import ConfigSection
|
||||
try:
|
||||
is_admin = user_info.get('role') == 'admin'
|
||||
config_section = self.query_one(ConfigSection)
|
||||
config_section.set_admin(is_admin)
|
||||
except Exception:
|
||||
pass
|
||||
is_admin = user_info.get('role') == 'admin'
|
||||
self.call_after_refresh(lambda: self._update_admin(is_admin))
|
||||
# 重新初始化后端
|
||||
self._init_after_login()
|
||||
|
||||
def _update_admin(self, is_admin: bool) -> None:
|
||||
from .widgets.config_section import ConfigSection
|
||||
try:
|
||||
config_section = self.query_one(ConfigSection)
|
||||
config_section.set_admin(is_admin)
|
||||
except Exception as e:
|
||||
print(f"配置区加载失败: {e}", file=sys.stderr)
|
||||
|
||||
def _init_after_login(self) -> None:
|
||||
"""登录后初始化"""
|
||||
from .widgets.status_bar import StatusBar
|
||||
|
||||
@ -88,8 +88,6 @@ class ConfigSection(Vertical):
|
||||
sep2.can_focus = False
|
||||
yield sep2
|
||||
|
||||
from textual.containers import Vertical
|
||||
|
||||
# Web 登录 — 仅 admin 可见
|
||||
with Vertical(id="admin-web-login-section"):
|
||||
web_title = Static("━━ Web 登录 ━━", classes="config-title")
|
||||
|
||||
Reference in New Issue
Block a user