diff --git a/eslint.config.mjs b/eslint.config.mjs index fcc952ed65..4635f287f5 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -48,7 +48,8 @@ export default defineConfig([ '@eslint-react/no-unstable-context-value': 'off', '@eslint-react/hooks-extra/prefer-use-state-lazy-initialization': 'off', '@eslint-react/hooks-extra/no-unnecessary-use-prefix': 'off', - '@eslint-react/no-children-to-array': 'off' + '@eslint-react/no-children-to-array': 'off', + '@eslint-react/dom/no-unsafe-iframe-sandbox': 'off' } }, { diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index b3d04b7abf..28b0f1fb19 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -3977,6 +3977,35 @@ }, "availableTools": "Available Tools", "enable": "Enable Tool", + "execute": { + "button": "Execute", + "copied": "Copied to clipboard", + "copy": "Copy", + "copyFailed": "Failed to copy", + "error": { + "invalidJson": "Invalid JSON format: {{error}}", + "noToolOrServer": "Tool or server not found" + }, + "execute": "Execute", + "label": "Execute", + "params": "Parameters (JSON)", + "paramsPlaceholder": "Enter JSON parameters...", + "result": { + "error": "Error Result", + "success": "Result", + "text": "Text" + }, + "table": { + "name": "Name", + "value": "Value" + }, + "title": "Execute Tool: {{name}}", + "tooltip": "Execute tool with custom parameters", + "view": { + "formatted": "Formatted", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "Allowed Values" @@ -3985,36 +4014,7 @@ }, "loadError": "Get tools Error", "noToolsAvailable": "No tools available", - "run": "Run", - "execute": { - "label": "Execute", - "button": "Execute", - "tooltip": "Execute tool with custom parameters", - "title": "Execute Tool: {{name}}", - "params": "Parameters (JSON)", - "paramsPlaceholder": "Enter JSON parameters...", - "execute": "Execute", - "copied": "Copied to clipboard", - "copyFailed": "Failed to copy", - "copy": "Copy", - "result": { - "success": "Result", - "error": "Error Result", - "text": "Text" - }, - "view": { - "json": "JSON", - "formatted": "Formatted" - }, - "table": { - "name": "Name", - "value": "Value" - }, - "error": { - "noToolOrServer": "Tool or server not found", - "invalidJson": "Invalid JSON format: {{error}}" - } - } + "run": "Run" }, "type": "Type", "types": { diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 57873468a3..a9405fb3df 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -3977,6 +3977,35 @@ }, "availableTools": "可用工具", "enable": "启用工具", + "execute": { + "button": "执行", + "copied": "已复制到剪贴板", + "copy": "复制", + "copyFailed": "复制失败", + "error": { + "invalidJson": "无效的 JSON 格式: {{error}}", + "noToolOrServer": "未找到工具或服务器" + }, + "execute": "执行", + "label": "执行", + "params": "参数 (JSON)", + "paramsPlaceholder": "输入 JSON 参数...", + "result": { + "error": "错误结果", + "success": "结果", + "text": "文本" + }, + "table": { + "name": "名称", + "value": "值" + }, + "title": "执行工具: {{name}}", + "tooltip": "使用自定义参数执行工具", + "view": { + "formatted": "美化", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "允许的值" @@ -3985,36 +4014,7 @@ }, "loadError": "获取工具失败", "noToolsAvailable": "无可用工具", - "run": "运行", - "execute": { - "label": "执行", - "button": "执行", - "tooltip": "使用自定义参数执行工具", - "title": "执行工具: {{name}}", - "params": "参数 (JSON)", - "paramsPlaceholder": "输入 JSON 参数...", - "execute": "执行", - "copied": "已复制到剪贴板", - "copyFailed": "复制失败", - "copy": "复制", - "result": { - "success": "结果", - "error": "错误结果", - "text": "文本" - }, - "view": { - "json": "JSON", - "formatted": "美化" - }, - "table": { - "name": "名称", - "value": "值" - }, - "error": { - "noToolOrServer": "未找到工具或服务器", - "invalidJson": "无效的 JSON 格式: {{error}}" - } - } + "run": "运行" }, "type": "类型", "types": { diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index f5a0264875..a150e8e84a 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -3977,6 +3977,35 @@ }, "availableTools": "可用工具", "enable": "啟用工具", + "execute": { + "button": "執行", + "copied": "已複製到剪貼板", + "copy": "複製", + "copyFailed": "複製失敗", + "error": { + "invalidJson": "無效的 JSON 格式: {{error}}", + "noToolOrServer": "未找到工具或伺服器" + }, + "execute": "執行", + "label": "執行", + "params": "參數 (JSON)", + "paramsPlaceholder": "輸入 JSON 參數...", + "result": { + "error": "錯誤結果", + "success": "結果", + "text": "文字" + }, + "table": { + "name": "名稱", + "value": "值" + }, + "title": "執行工具: {{name}}", + "tooltip": "使用自訂參數執行工具", + "view": { + "formatted": "美化", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "允許的值" diff --git a/src/renderer/src/i18n/translate/de-de.json b/src/renderer/src/i18n/translate/de-de.json index 597259d919..5dcfac34f3 100644 --- a/src/renderer/src/i18n/translate/de-de.json +++ b/src/renderer/src/i18n/translate/de-de.json @@ -3977,6 +3977,35 @@ }, "availableTools": "Verfügbare Tools", "enable": "Tool aktivieren", + "execute": { + "button": "Ausführen", + "copied": "In Zwischenablage kopiert", + "copy": "Kopieren", + "copyFailed": "Kopieren fehlgeschlagen", + "error": { + "invalidJson": "Ungültiges JSON-Format: {{error}}", + "noToolOrServer": "Tool oder Server nicht gefunden" + }, + "execute": "Ausführen", + "label": "Ausführen", + "params": "Parameter (JSON)", + "paramsPlaceholder": "JSON-Parameter eingeben...", + "result": { + "error": "Fehlerergebnis", + "success": "Ergebnis", + "text": "Text" + }, + "table": { + "name": "Name", + "value": "Wert" + }, + "title": "Tool ausführen: {{name}}", + "tooltip": "Tool mit benutzerdefinierten Parametern ausführen", + "view": { + "formatted": "Formatiert", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "Erlaubte Werte" diff --git a/src/renderer/src/i18n/translate/el-gr.json b/src/renderer/src/i18n/translate/el-gr.json index d7cf3b8cff..4d37f629db 100644 --- a/src/renderer/src/i18n/translate/el-gr.json +++ b/src/renderer/src/i18n/translate/el-gr.json @@ -3977,6 +3977,35 @@ }, "availableTools": "Διαθέσιμα Εργαλεία", "enable": "Ενεργοποίηση εργαλείου", + "execute": { + "button": "Εκτέλεση", + "copied": "Αντιγράφηκε στο πρόχειρο", + "copy": "Αντιγραφή", + "copyFailed": "Αποτυχία αντιγραφής", + "error": { + "invalidJson": "Μη έγκυρη μορφή JSON: {{error}}", + "noToolOrServer": "Εργαλείο ή διακομιστής δεν βρέθηκε" + }, + "execute": "Εκτέλεση", + "label": "Εκτέλεση", + "params": "Παράμετροι (JSON)", + "paramsPlaceholder": "Εισαγάγετε παραμέτρους JSON...", + "result": { + "error": "Αποτέλεσμα σφάλματος", + "success": "Αποτέλεσμα", + "text": "Κείμενο" + }, + "table": { + "name": "Όνομα", + "value": "Τιμή" + }, + "title": "Εκτέλεση εργαλείου: {{name}}", + "tooltip": "Εκτέλεση εργαλείου με προσαρμοσμένες παραμέτρους", + "view": { + "formatted": "Μορφοποιημένο", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "Επιτρεπόμενες τιμές" diff --git a/src/renderer/src/i18n/translate/es-es.json b/src/renderer/src/i18n/translate/es-es.json index 7c857e9efc..1a9de08587 100644 --- a/src/renderer/src/i18n/translate/es-es.json +++ b/src/renderer/src/i18n/translate/es-es.json @@ -3977,6 +3977,35 @@ }, "availableTools": "Herramientas disponibles", "enable": "Habilitar herramienta", + "execute": { + "button": "Ejecutar", + "copied": "Copiado al portapapeles", + "copy": "Copiar", + "copyFailed": "Error al copiar", + "error": { + "invalidJson": "Formato JSON inválido: {{error}}", + "noToolOrServer": "Herramienta o servidor no encontrado" + }, + "execute": "Ejecutar", + "label": "Ejecutar", + "params": "Parámetros (JSON)", + "paramsPlaceholder": "Ingrese parámetros JSON...", + "result": { + "error": "Resultado de error", + "success": "Resultado", + "text": "Texto" + }, + "table": { + "name": "Nombre", + "value": "Valor" + }, + "title": "Ejecutar herramienta: {{name}}", + "tooltip": "Ejecutar herramienta con parámetros personalizados", + "view": { + "formatted": "Formateado", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "Valores permitidos" diff --git a/src/renderer/src/i18n/translate/fr-fr.json b/src/renderer/src/i18n/translate/fr-fr.json index a9025e404e..38e1845555 100644 --- a/src/renderer/src/i18n/translate/fr-fr.json +++ b/src/renderer/src/i18n/translate/fr-fr.json @@ -3977,6 +3977,35 @@ }, "availableTools": "Outils disponibles", "enable": "Activer l'outil", + "execute": { + "button": "Exécuter", + "copied": "Copié dans le presse-papiers", + "copy": "Copier", + "copyFailed": "Échec de la copie", + "error": { + "invalidJson": "Format JSON invalide: {{error}}", + "noToolOrServer": "Outil ou serveur introuvable" + }, + "execute": "Exécuter", + "label": "Exécuter", + "params": "Paramètres (JSON)", + "paramsPlaceholder": "Entrez les paramètres JSON...", + "result": { + "error": "Résultat d'erreur", + "success": "Résultat", + "text": "Texte" + }, + "table": { + "name": "Nom", + "value": "Valeur" + }, + "title": "Exécuter l'outil: {{name}}", + "tooltip": "Exécuter l'outil avec des paramètres personnalisés", + "view": { + "formatted": "Formaté", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "Valeurs autorisées" diff --git a/src/renderer/src/i18n/translate/ja-jp.json b/src/renderer/src/i18n/translate/ja-jp.json index 1559b450da..972b47a6a8 100644 --- a/src/renderer/src/i18n/translate/ja-jp.json +++ b/src/renderer/src/i18n/translate/ja-jp.json @@ -3977,6 +3977,35 @@ }, "availableTools": "利用可能なツール", "enable": "ツールを有効にする", + "execute": { + "button": "実行", + "copied": "クリップボードにコピーしました", + "copy": "コピー", + "copyFailed": "コピーに失敗しました", + "error": { + "invalidJson": "無効なJSON形式: {{error}}", + "noToolOrServer": "ツールまたはサーバーが見つかりません" + }, + "execute": "実行", + "label": "実行", + "params": "パラメータ (JSON)", + "paramsPlaceholder": "JSONパラメータを入力...", + "result": { + "error": "エラー結果", + "success": "結果", + "text": "テキスト" + }, + "table": { + "name": "名前", + "value": "値" + }, + "title": "ツールを実行: {{name}}", + "tooltip": "カスタムパラメータでツールを実行", + "view": { + "formatted": "フォーマット済み", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "許可された値" diff --git a/src/renderer/src/i18n/translate/pt-pt.json b/src/renderer/src/i18n/translate/pt-pt.json index eb55076143..fa6d5309f8 100644 --- a/src/renderer/src/i18n/translate/pt-pt.json +++ b/src/renderer/src/i18n/translate/pt-pt.json @@ -3977,6 +3977,35 @@ }, "availableTools": "Ferramentas Disponíveis", "enable": "Habilitar Ferramenta", + "execute": { + "button": "Executar", + "copied": "Copiado para a área de transferência", + "copy": "Copiar", + "copyFailed": "Falha ao copiar", + "error": { + "invalidJson": "Formato JSON inválido: {{error}}", + "noToolOrServer": "Ferramenta ou servidor não encontrado" + }, + "execute": "Executar", + "label": "Executar", + "params": "Parâmetros (JSON)", + "paramsPlaceholder": "Digite os parâmetros JSON...", + "result": { + "error": "Resultado de erro", + "success": "Resultado", + "text": "Texto" + }, + "table": { + "name": "Nome", + "value": "Valor" + }, + "title": "Executar ferramenta: {{name}}", + "tooltip": "Executar ferramenta com parâmetros personalizados", + "view": { + "formatted": "Formatado", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "Valores permitidos" diff --git a/src/renderer/src/i18n/translate/ru-ru.json b/src/renderer/src/i18n/translate/ru-ru.json index c9e4fc6fc4..a2e695bfbd 100644 --- a/src/renderer/src/i18n/translate/ru-ru.json +++ b/src/renderer/src/i18n/translate/ru-ru.json @@ -3977,6 +3977,35 @@ }, "availableTools": "Доступные инструменты", "enable": "Включить инструмент", + "execute": { + "button": "Выполнить", + "copied": "Скопировано в буфер обмена", + "copy": "Копировать", + "copyFailed": "Не удалось скопировать", + "error": { + "invalidJson": "Неверный формат JSON: {{error}}", + "noToolOrServer": "Инструмент или сервер не найден" + }, + "execute": "Выполнить", + "label": "Выполнить", + "params": "Параметры (JSON)", + "paramsPlaceholder": "Введите параметры JSON...", + "result": { + "error": "Результат ошибки", + "success": "Результат", + "text": "Текст" + }, + "table": { + "name": "Имя", + "value": "Значение" + }, + "title": "Выполнить инструмент: {{name}}", + "tooltip": "Выполнить инструмент с пользовательскими параметрами", + "view": { + "formatted": "Форматированный", + "json": "JSON" + } + }, "inputSchema": { "enum": { "allowedValues": "Допустимые значения" diff --git a/src/renderer/src/pages/settings/MCPSettings/ExecuteToolModal.tsx b/src/renderer/src/pages/settings/MCPSettings/ExecuteToolModal.tsx index e9dc4995de..dbfaa3184d 100644 --- a/src/renderer/src/pages/settings/MCPSettings/ExecuteToolModal.tsx +++ b/src/renderer/src/pages/settings/MCPSettings/ExecuteToolModal.tsx @@ -1,18 +1,18 @@ import 'katex/dist/katex.min.css' -import type { MCPServer, MCPTool } from '@renderer/types' import { loggerService } from '@logger' -import { Button, Flex, Input, Modal, Space, Table, Typography, message } from 'antd' +import type { MCPServer, MCPTool } from '@renderer/types' +import { Button, Flex, Input, message, Modal, Space, Table, Typography } from 'antd' import type { ColumnsType } from 'antd/es/table' -import { Copy, Play, Sparkles, Code as CodeIcon } from 'lucide-react' -import { useState, useMemo, useEffect } from 'react' +import { Code as CodeIcon, Copy, Play, Sparkles } from 'lucide-react' +import { useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import ReactMarkdown from 'react-markdown' -import remarkGfm from 'remark-gfm' -import remarkMath from 'remark-math' import rehypeKatex from 'rehype-katex' import rehypeRaw from 'rehype-raw' import remarkCjkFriendly from 'remark-cjk-friendly' +import remarkGfm from 'remark-gfm' +import remarkMath from 'remark-math' const logger = loggerService.withContext('ExecuteToolModal') @@ -47,7 +47,10 @@ const ExecuteToolModal: React.FC = ({ open, tool, server, // 为每个属性生成默认值或示例 Object.keys(properties).forEach((key) => { - const prop = properties[key] + const prop = properties[key] as { + type?: string + default?: any + } if (prop.type === 'string') { params[key] = prop.default || '' } else if (prop.type === 'number') { @@ -79,12 +82,7 @@ const ExecuteToolModal: React.FC = ({ open, tool, server, // 检测 HTML 特征(优先检测,因为 HTML 可能包含其他格式) // 检查是否包含完整的 HTML 文档结构或大量 HTML 标签 - const htmlDocumentPatterns = [ - /]/i, - /]/i, - /]/i - ] + const htmlDocumentPatterns = [/]/i, /]/i, /]/i] const hasHtmlDocument = htmlDocumentPatterns.some((pattern) => pattern.test(text)) @@ -313,9 +311,7 @@ const ExecuteToolModal: React.FC = ({ open, tool, server, {/* 参数输入 */}
- - {t('settings.mcp.tools.execute.params', 'Parameters (JSON)')} - + {t('settings.mcp.tools.execute.params', 'Parameters (JSON)')} setParamsJson(e.target.value)} @@ -435,4 +431,3 @@ const ExecuteToolModal: React.FC = ({ open, tool, server, } export default ExecuteToolModal - diff --git a/src/renderer/src/pages/settings/MCPSettings/McpTool.tsx b/src/renderer/src/pages/settings/MCPSettings/McpTool.tsx index aeb00e8bc9..8795f7c60a 100644 --- a/src/renderer/src/pages/settings/MCPSettings/McpTool.tsx +++ b/src/renderer/src/pages/settings/MCPSettings/McpTool.tsx @@ -5,6 +5,7 @@ import type { ColumnsType } from 'antd/es/table' import { Hammer, Info, Play, Zap } from 'lucide-react' import { useState } from 'react' import { useTranslation } from 'react-i18next' + import ExecuteToolModal from './ExecuteToolModal' interface MCPToolsSectionProps {