多用户系统 + 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:
root
2026-04-28 10:37:57 +08:00
parent 46008c14c5
commit b4456a9c5b
22 changed files with 5488 additions and 183 deletions

View File

@ -85,6 +85,44 @@ class BackendClient:
)
response = self._server.send(packet)
return response.body.get("data", {})
def get_web_users(self) -> list:
"""获取 Web 用户列表"""
packet = Packet(
id=self._next_id(),
type=PacketType.GET_WEB_USERS,
body={}
)
return self._server.send(packet).body.get("users", [])
def set_web_user(self, username: str, password: str) -> Dict:
"""设置 Web 用户"""
packet = Packet(
id=self._next_id(),
type=PacketType.SET_WEB_USER,
body={"username": username, "password": password}
)
return self._server.send(packet).body.get("data", {"success": False})
def get_full_config(self) -> Dict:
"""获取完整配置"""
packet = Packet(
id=self._next_id(),
type=PacketType.GET_CONFIG,
body={}
)
response = self._server.send(packet)
return response.body if response.body else {"api_config": {}, "tool_limits": {}}
def report_web_status(self, running: bool, port: int = 4096) -> Dict:
"""向后端报告 Web 服务运行状态"""
packet = Packet(
id=self._next_id(),
type=PacketType.GET_WEB_SERVICE_STATUS,
body={"running": running, "port": port}
)
response = self._server.send(packet)
return response.body if response.body else {"success": False}
def shutdown(self) -> None:
self._server.shutdown()