feat: system knowledge base management with admin/user role separation

- Auto-create system KBs from data/knowledge_base/ subdirectories on startup
- Upgrade existing user KBs to system KBs when matching directory found
- Admin can upload to system KBs (saved to knowledge_base dir)
- Regular users see only their own KBs on knowledge page
- Fix API permission checks for system KBs (list, detail, documents, update, delete)
- Add is_superuser to UserResponse and frontend User type
- Fix sidebar session menu visibility for long titles

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 16:42:28 +08:00
parent 1ce689ad1e
commit 38865b0f7d
10 changed files with 344 additions and 129 deletions
@@ -132,6 +132,10 @@ class FileWatcherService:
print(f"文件监控服务已启动,监控目录: {self.knowledge_base_dir}")
# 确保子目录对应的系统知识库存在
print("确保系统知识库与目录同步...")
kb_service.ensure_system_knowledge_bases()
# 执行初始扫描
print("执行初始知识库扫描...")
scan_result = kb_service.scan_directory()