From 8097f227cabf60dd6d5f75a8a57694cd95945244 Mon Sep 17 00:00:00 2001 From: yujiangping Date: Fri, 13 Mar 2026 17:34:18 +0800 Subject: [PATCH] feat(mcp market): Add configuration update notification and refactor MCP list fetching - Add marketConfigUpdated i18n message in English and Chinese translations - Replace inline MCP list fetching logic with fetchMcpList function call - Improve code maintainability by centralizing MCP list retrieval logic - Ensure consistent handling of MCP list state across configuration updates --- web/src/i18n/en.ts | 1 + web/src/i18n/zh.ts | 1 + web/src/views/ToolManagement/Market.tsx | 16 ++-------------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index ce357e74..6a980f36 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -1997,6 +1997,7 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re marketConnected: '● Connected', marketDisconnected: '○ Disconnected', marketConnecting: 'Connecting to {{name}}...', + marketConfigUpdated: '{{name}} configuration updated', serverUrlInvalid: 'Must start with http:// or https://, and cannot have leading or trailing spaces', requestHeaderKeyInvalid: 'Only English letters, numbers, hyphens (-), and underscores (_) are allowed, and cannot start or end with a hyphen or underscore', }, diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index 01b1ab9e..974fc478 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -1993,6 +1993,7 @@ export const zh = { marketConnected: '● 已连接', marketDisconnected: '○ 未连接', marketConnecting: '正在连接 {{name}}...', + marketConfigUpdated: '{{name}} 配置已更新', serverUrlInvalid: '必须以 http:// 或 https:// 开头,且不能有前后空格', requestHeaderKeyInvalid: '只支持英文、数字、连字符(-)、下划线(_),不能以连字符或下划线开头结尾', }, diff --git a/web/src/views/ToolManagement/Market.tsx b/web/src/views/ToolManagement/Market.tsx index e6250e71..310637d7 100644 --- a/web/src/views/ToolManagement/Market.tsx +++ b/web/src/views/ToolManagement/Market.tsx @@ -307,20 +307,8 @@ const Market: React.FC<{ getStatusTag?: (status: string) => ReactNode }> = () => })); setConfigIdMap(prev => ({ ...prev, [sourceId]: configId })); - // 用 configId 获取第一页 MCP 列表 - try { - const res: any = await getMarketMCPs({ mcp_market_config_id: configId, page: 1, pagesize: pageSize }); - if (res?.items && Array.isArray(res.items)) { - setMcpCache(prev => ({ ...prev, [sourceId]: res.items })); - } - if (res?.page) { - setMcpTotal(res.page.total || 0); - setHasMore(!!res.page.has_next); - setCurrentPage(1); - } - } catch (error) { - console.error('获取 MCP 列表失败:', error); - } + // 使用 fetchMcpList 获取完整的 MCP 列表(包含激活状态和入库状态) + await fetchMcpList(sourceId, 1); }; const handleRefreshAfterAdd = async () => {