fix: prevent exporting empty MCP server selection (#16589)

This commit is contained in:
euvre
2026-07-03 14:22:17 +08:00
committed by GitHub
parent ac5d0c4615
commit 7b341539e7
3 changed files with 11 additions and 3 deletions

View File

@@ -3020,6 +3020,7 @@ Important structured information may include: names, dates, locations, events, k
bulkManage: 'Bulk manage',
exitBulkManage: 'Exit bulk manage',
selected: 'Selected',
noServerSelected: 'Please select at least one MCP server',
},
search: {
searchApps: 'Search apps',

View File

@@ -2603,6 +2603,7 @@ Tokenizer 会根据所选方式将内容存储为对应的数据结构。`,
selected: '已选择',
bulkManage: '批量管理',
exitBulkManage: '退出批量管理',
noServerSelected: '请至少选择一个 MCP 服务器',
},
search: {
searchApps: '搜索',

View File

@@ -1,16 +1,22 @@
import message from '@/components/ui/message';
import { useExportMcpServer } from '@/hooks/use-mcp-request';
import { IMcpServer } from '@/interfaces/database/mcp';
import { downloadJsonFile } from '@/utils/file-util';
import i18n from '@/locales/config';
import { useCallback } from 'react';
export function useExportMcp(mcp: IMcpServer) {
export function useExportMcp(mcp?: IMcpServer) {
const { exportMcpServer } = useExportMcpServer();
const handleExportMcpJson = useCallback(
(ids: string[]) => async () => {
if (ids.length === 0) {
message.warning(i18n.t('mcp.noServerSelected'));
return;
}
const data = await exportMcpServer(ids);
if (data.code === 0 && mcp) {
downloadJsonFile(data.data, `${mcp.name || 'mcp'}.json`);
if (data.code === 0) {
downloadJsonFile(data.data, `${mcp?.name || 'mcp'}.json`);
}
},
[exportMcpServer, mcp],