feat: restore core admin modules and harden ai model fallback
This commit is contained in:
@@ -17,13 +17,14 @@ from core.menu.schema import MenuCreate, MenuUpdate
|
||||
menu_cache = CacheManager(prefix="menu:")
|
||||
|
||||
# 缓存key
|
||||
AI_AGENT_ADMIN_MENU_CACHE_VERSION = "v16"
|
||||
AI_AGENT_ADMIN_MENU_CACHE_VERSION = "v19"
|
||||
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",
|
||||
"Application",
|
||||
"AIPlatform",
|
||||
"AIAgent",
|
||||
"AIModelConfig",
|
||||
@@ -39,6 +40,10 @@ AI_AGENT_ADMIN_MENU_NAMES = {
|
||||
"SystemPost",
|
||||
"SystemDict",
|
||||
"SystemFileManager",
|
||||
"LoginLog",
|
||||
"OrgNode",
|
||||
"SystemLoginLog",
|
||||
"SystemOrgChart",
|
||||
"SystemRole",
|
||||
"SystemConfigManager",
|
||||
"UIConfigManager",
|
||||
@@ -50,6 +55,7 @@ AI_AGENT_ADMIN_MENU_NAMES = {
|
||||
|
||||
AI_AGENT_ADMIN_VISIBLE_MENU_NAMES = {
|
||||
"ControlCenter",
|
||||
"Application",
|
||||
"AIPlatform",
|
||||
"AIAgent",
|
||||
"AIModelConfig",
|
||||
@@ -65,6 +71,10 @@ AI_AGENT_ADMIN_VISIBLE_MENU_NAMES = {
|
||||
"SystemPost",
|
||||
"SystemDict",
|
||||
"SystemFileManager",
|
||||
"LoginLog",
|
||||
"OrgNode",
|
||||
"SystemLoginLog",
|
||||
"SystemOrgChart",
|
||||
"SystemRole",
|
||||
"SystemConfigManager",
|
||||
"UIConfigManager",
|
||||
@@ -82,10 +92,29 @@ AI_AGENT_ADMIN_SYSTEM_CHILD_MENU_NAMES = {
|
||||
"SystemPost",
|
||||
"SystemDict",
|
||||
"SystemFileManager",
|
||||
"LoginLog",
|
||||
"OrgNode",
|
||||
"SystemLoginLog",
|
||||
"SystemOrgChart",
|
||||
"SystemRole",
|
||||
"UIConfigManager",
|
||||
}
|
||||
|
||||
AI_AGENT_ADMIN_AI_CHILD_MENU_NAMES = {
|
||||
"AIAgent",
|
||||
"AIModelConfig",
|
||||
"AIWorkflow",
|
||||
"AIWorkflowRuns",
|
||||
"CodexAgentChat",
|
||||
"KnowledgeBase",
|
||||
}
|
||||
|
||||
AI_AGENT_ADMIN_MESSAGE_CHILD_MENU_NAMES = {
|
||||
"AnnouncementList",
|
||||
"AnnouncementManage",
|
||||
"MessageList",
|
||||
}
|
||||
|
||||
AI_AGENT_ADMIN_MENU_OVERRIDES = {
|
||||
"SystemConfigManager": {
|
||||
"component": "/_core/system-config/index",
|
||||
@@ -100,6 +129,16 @@ AI_AGENT_ADMIN_MENU_OVERRIDES = {
|
||||
"component": "/_core/file-manager/index",
|
||||
"path": "/system/file-manager",
|
||||
},
|
||||
"LoginLog": {
|
||||
"component": "/_core/login-log/index",
|
||||
"path": "/system/login-log",
|
||||
"title": "menu-title.loginLog",
|
||||
},
|
||||
"OrgNode": {
|
||||
"component": "/_core/org-chart/index",
|
||||
"path": "/system/org-chart",
|
||||
"title": "menu-title.orgChart",
|
||||
},
|
||||
"UIConfigManager": {
|
||||
"component": "/_core/ui-config/index",
|
||||
"path": "/system/ui-config",
|
||||
@@ -131,19 +170,33 @@ def _normalize_ai_agent_admin_menu(menu: Menu) -> None:
|
||||
|
||||
|
||||
def _normalize_ai_agent_admin_parentage(menus: List[Menu]) -> None:
|
||||
"""Attach retained system children back to the lightweight system catalog."""
|
||||
"""Attach retained children back to the lightweight product catalogs."""
|
||||
retained_ids = {menu.id for menu in menus}
|
||||
system_menu = next(
|
||||
(menu for menu in menus if menu.name == "SystemManagement"),
|
||||
None,
|
||||
)
|
||||
ai_menu = next(
|
||||
(menu for menu in menus if menu.name == "AIPlatform"),
|
||||
None,
|
||||
)
|
||||
message_menu = next(
|
||||
(menu for menu in menus if menu.name == "Message"),
|
||||
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
|
||||
continue
|
||||
if ai_menu and menu.name in AI_AGENT_ADMIN_AI_CHILD_MENU_NAMES:
|
||||
menu.parent_id = ai_menu.id
|
||||
continue
|
||||
if message_menu and menu.name in AI_AGENT_ADMIN_MESSAGE_CHILD_MENU_NAMES:
|
||||
menu.parent_id = message_menu.id
|
||||
continue
|
||||
if not menu.parent_id or menu.parent_id in retained_ids:
|
||||
continue
|
||||
menu.parent_id = None
|
||||
|
||||
|
||||
class MenuService(BaseService[Menu, MenuCreate, MenuUpdate]):
|
||||
|
||||
Reference in New Issue
Block a user