Skip to content

Commit db43713

Browse files
authored
refactor(mcp): 优化 Monaco 编辑器的加载方式 (higress-group#571)
1 parent 874758c commit db43713

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

frontend/src/pages/mcp/components/EditToolDrawer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import React, { useState, useEffect } from 'react';
22
import { Drawer, Button, Space, message, Card } from 'antd';
33
import { useTranslation } from 'react-i18next';
4-
import MonacoEditor from '@monaco-editor/react';
54
import StepTitle from './StepTitle';
65
import YamlUtil from './yamlUtil';
76
import { swaggerToMcpConfig } from '@/services/mcp';
7+
import MonacoEditor, { loader } from '@monaco-editor/react';
8+
import * as monaco from 'monaco-editor';
9+
10+
loader.config({ monaco });
811

912
interface EditToolDrawerProps {
1013
visible: boolean;

frontend/src/pages/mcp/components/McpServerCommand.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { Select, message, Button } from 'antd';
33
import { useSearchParams } from 'ice';
44
import { CLIENT_MAP } from '../constant';
55
import { useTranslation, Trans } from 'react-i18next';
6-
import MonacoEditor from '@monaco-editor/react';
6+
import MonacoEditor, { loader } from '@monaco-editor/react';
7+
import * as monaco from 'monaco-editor';
8+
9+
loader.config({ monaco });
710

811
interface McpServerCommandProps {
912
mode: 'streamableHttp' | 'sse';

frontend/src/pages/mcp/detail.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ import DeleteConfirm from './components/DeleteConfirm';
2727
import McpServerCommand from './components/McpServerCommand';
2828
import AddConsumerAuth from './components/AddConsumerAuth';
2929
import YamlUtil from './components/yamlUtil';
30-
import MonacoEditor from '@monaco-editor/react';
30+
import MonacoEditor, { loader } from '@monaco-editor/react';
31+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
32+
33+
loader.config({ monaco });
3134

3235
const MCPDetailPage: React.FC = () => {
3336
const { t } = useTranslation();

0 commit comments

Comments
 (0)