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
This commit is contained in:
@@ -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',
|
||||
},
|
||||
|
||||
@@ -1993,6 +1993,7 @@ export const zh = {
|
||||
marketConnected: '● 已连接',
|
||||
marketDisconnected: '○ 未连接',
|
||||
marketConnecting: '正在连接 {{name}}...',
|
||||
marketConfigUpdated: '{{name}} 配置已更新',
|
||||
serverUrlInvalid: '必须以 http:// 或 https:// 开头,且不能有前后空格',
|
||||
requestHeaderKeyInvalid: '只支持英文、数字、连字符(-)、下划线(_),不能以连字符或下划线开头结尾',
|
||||
},
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user