feat: restore lightweight admin modules
This commit is contained in:
@@ -17,11 +17,12 @@ from core.menu.schema import MenuCreate, MenuUpdate
|
||||
menu_cache = CacheManager(prefix="menu:")
|
||||
|
||||
# 缓存key
|
||||
AI_AGENT_ADMIN_MENU_CACHE_VERSION = "v13"
|
||||
AI_AGENT_ADMIN_MENU_CACHE_VERSION = "v16"
|
||||
MENU_TREE_CACHE_KEY = f"tree:ai_agent_admin:{AI_AGENT_ADMIN_MENU_CACHE_VERSION}"
|
||||
USER_ROUTE_CACHE_PREFIX = f"user_route:ai_agent_admin:{AI_AGENT_ADMIN_MENU_CACHE_VERSION}:"
|
||||
|
||||
AI_AGENT_ADMIN_MENU_NAMES = {
|
||||
"AccountSettings",
|
||||
"ControlCenter",
|
||||
"AIPlatform",
|
||||
"AIAgent",
|
||||
@@ -33,29 +34,116 @@ AI_AGENT_ADMIN_MENU_NAMES = {
|
||||
"SystemManagement",
|
||||
"SystemPermission",
|
||||
"UserManagement",
|
||||
"SystemDept",
|
||||
"SystemMenu",
|
||||
"SystemPost",
|
||||
"SystemDict",
|
||||
"SystemFileManager",
|
||||
"SystemRole",
|
||||
"SystemConfigManager",
|
||||
"UIConfigManager",
|
||||
"Message",
|
||||
"MessageList",
|
||||
"AnnouncementList",
|
||||
"AnnouncementManage",
|
||||
}
|
||||
|
||||
AI_AGENT_ADMIN_VISIBLE_MENU_NAMES = {
|
||||
"ControlCenter",
|
||||
"AIPlatform",
|
||||
"AIAgent",
|
||||
"AIModelConfig",
|
||||
"AIWorkflow",
|
||||
"AIWorkflowRuns",
|
||||
"CodexAgentChat",
|
||||
"KnowledgeBase",
|
||||
"SystemManagement",
|
||||
"SystemPermission",
|
||||
"UserManagement",
|
||||
"SystemDept",
|
||||
"SystemMenu",
|
||||
"SystemPost",
|
||||
"SystemDict",
|
||||
"SystemFileManager",
|
||||
"SystemRole",
|
||||
"SystemConfigManager",
|
||||
"UIConfigManager",
|
||||
"Message",
|
||||
"MessageList",
|
||||
"AnnouncementList",
|
||||
"AnnouncementManage",
|
||||
}
|
||||
|
||||
AI_AGENT_ADMIN_SYSTEM_CHILD_MENU_NAMES = {
|
||||
"SystemPermission",
|
||||
"UserManagement",
|
||||
"SystemDept",
|
||||
"SystemMenu",
|
||||
"SystemPost",
|
||||
"SystemDict",
|
||||
"SystemFileManager",
|
||||
"SystemRole",
|
||||
"UIConfigManager",
|
||||
}
|
||||
|
||||
AI_AGENT_ADMIN_MENU_OVERRIDES = {
|
||||
"SystemConfigManager": {
|
||||
"component": "/_core/system-config/index",
|
||||
"path": "/system-config",
|
||||
"title": "系统配置",
|
||||
},
|
||||
"SystemDict": {
|
||||
"component": "/_core/dict/index",
|
||||
"path": "/system/dict",
|
||||
},
|
||||
"SystemFileManager": {
|
||||
"component": "/_core/file-manager/index",
|
||||
"path": "/system/file-manager",
|
||||
},
|
||||
"UIConfigManager": {
|
||||
"component": "/_core/ui-config/index",
|
||||
"path": "/system/ui-config",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _filter_ai_agent_admin_menus(menus: List[Menu]) -> List[Menu]:
|
||||
"""Keep only the lightweight admin and AI modules for this product."""
|
||||
filtered = [menu for menu in menus if menu.name in AI_AGENT_ADMIN_MENU_NAMES]
|
||||
for menu in filtered:
|
||||
_normalize_ai_agent_admin_menu(menu)
|
||||
_normalize_ai_agent_admin_parentage(filtered)
|
||||
return filtered
|
||||
|
||||
|
||||
def _normalize_ai_agent_admin_menu(menu: Menu) -> None:
|
||||
"""Keep the retained control center on the original configurable dashboard."""
|
||||
overrides = AI_AGENT_ADMIN_MENU_OVERRIDES.get(menu.name)
|
||||
if overrides:
|
||||
for key, value in overrides.items():
|
||||
setattr(menu, key, value)
|
||||
if menu.name == "ControlCenter":
|
||||
menu.path = "/page-render/main_home"
|
||||
menu.component = "/_core/page-render/index"
|
||||
menu.query = {"pageCode": "main_home"}
|
||||
if menu.name in AI_AGENT_ADMIN_VISIBLE_MENU_NAMES:
|
||||
menu.hideInMenu = False
|
||||
|
||||
|
||||
def _normalize_ai_agent_admin_parentage(menus: List[Menu]) -> None:
|
||||
"""Attach retained system children back to the lightweight system catalog."""
|
||||
retained_ids = {menu.id for menu in menus}
|
||||
system_menu = next(
|
||||
(menu for menu in menus if menu.name == "SystemManagement"),
|
||||
None,
|
||||
)
|
||||
for menu in menus:
|
||||
if not menu.parent_id or menu.parent_id in retained_ids:
|
||||
continue
|
||||
if system_menu and menu.name in AI_AGENT_ADMIN_SYSTEM_CHILD_MENU_NAMES:
|
||||
menu.parent_id = system_menu.id
|
||||
else:
|
||||
menu.parent_id = None
|
||||
|
||||
|
||||
class MenuService(BaseService[Menu, MenuCreate, MenuUpdate]):
|
||||
|
||||
Reference in New Issue
Block a user