多用户系统 + Admin 角色权限 + Web/TUI 同步 + 构建集成
本轮实现功能: 1. 多用户隔离:每个用户独立 config.json + graph.db 2. TUI 登录页 + 旧版自动迁移(core/migrate.py) 3. Admin/User 角色体系(core/embedded_db.py) 4. Web 后台管理 API(userinfo + admin CRUD) 5. Web 设置页用户管理区(仅 admin 可见) 6. TUI 侧栏配置区权限同步(非 admin 隐藏 Web 服务设置) 7. Web 服务打包为独立二进制(trulymem-web) 8. 双入口 PyInstaller 构建脚本(TUI + Web) 9. 活动记录器(core/activity_recorder.py) 10. 静态页面模板(登录/设置/首次引导)
This commit is contained in:
@ -17,9 +17,25 @@ class AppConfig:
|
||||
task_update_max: int = 5
|
||||
memory_query_max: int = 20
|
||||
memory_update_max: int = 10
|
||||
web_username: str = ""
|
||||
web_password: str = ""
|
||||
enable_web: bool = False
|
||||
web_port: int = 4096
|
||||
enable_tui: bool = True
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "AppConfig":
|
||||
def from_env(cls, username: str = "") -> "AppConfig":
|
||||
"""
|
||||
从环境变量加载配置。
|
||||
如果指定了 username,尝试从用户的配置文件加载。
|
||||
"""
|
||||
# 如果指定了用户名,尝试从用户的配置文件加载
|
||||
if username:
|
||||
from pathlib import Path
|
||||
user_config_path = Path.home() / ".trulymem" / username / "config.json"
|
||||
if user_config_path.exists():
|
||||
return cls.from_file(user_config_path)
|
||||
|
||||
return cls(
|
||||
api_key=os.getenv("DEEPSEEK_API_KEY", ""),
|
||||
model=os.getenv("MODEL_NAME", "deepseek-chat"),
|
||||
@ -28,6 +44,11 @@ class AppConfig:
|
||||
task_update_max=int(os.getenv("TASK_UPDATE_MAX", 5)),
|
||||
memory_query_max=int(os.getenv("MEMORY_QUERY_MAX", 20)),
|
||||
memory_update_max=int(os.getenv("MEMORY_UPDATE_MAX", 10)),
|
||||
web_username=os.getenv("WEB_USERNAME", ""),
|
||||
web_password=os.getenv("WEB_PASSWORD", ""),
|
||||
enable_web=os.getenv("ENABLE_WEB", "false").lower() == "true",
|
||||
web_port=int(os.getenv("WEB_PORT", 4096)),
|
||||
enable_tui=os.getenv("ENABLE_TUI", "true").lower() == "true",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@ -46,6 +67,11 @@ class AppConfig:
|
||||
task_update_max=data.get("task_update_max", 5),
|
||||
memory_query_max=data.get("memory_query_max", 20),
|
||||
memory_update_max=data.get("memory_update_max", 10),
|
||||
web_username=data.get("web_username", ""),
|
||||
web_password=data.get("web_password", ""),
|
||||
enable_web=data.get("enable_web", False),
|
||||
web_port=data.get("web_port", 4096),
|
||||
enable_tui=data.get("enable_tui", True),
|
||||
)
|
||||
|
||||
def save(self, path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user