Fix: pass mcp to useExportMcp for correct JSON export filename (#16564)

This commit is contained in:
chanx
2026-07-02 17:49:46 +08:00
committed by GitHub
parent c44d56f1bb
commit 2ef78189ce
2 changed files with 6 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ export function McpOperation({
}: { mcp: IMcpServer } & Pick<UseEditMcpReturnType, 'showEditModal'>) {
const { t } = useTranslation();
const { deleteMcpServer } = useDeleteMcpServer();
const { handleExportMcpJson } = useExportMcp();
const { handleExportMcpJson } = useExportMcp(mcp);
const handleDelete: MouseEventHandler<HTMLDivElement> = useCallback(() => {
deleteMcpServer([mcp.id]);

View File

@@ -1,18 +1,19 @@
import { useExportMcpServer } from '@/hooks/use-mcp-request';
import { IMcpServer } from '@/interfaces/database/mcp';
import { downloadJsonFile } from '@/utils/file-util';
import { useCallback } from 'react';
export function useExportMcp() {
export function useExportMcp(mcp: IMcpServer) {
const { exportMcpServer } = useExportMcpServer();
const handleExportMcpJson = useCallback(
(ids: string[]) => async () => {
const data = await exportMcpServer(ids);
if (data.code === 0) {
downloadJsonFile(data.data, `mcp.json`);
if (data.code === 0 && mcp) {
downloadJsonFile(data.data, `${mcp.name || 'mcp'}.json`);
}
},
[exportMcpServer],
[exportMcpServer, mcp],
);
return {