update hello view page

This commit is contained in:
duanfuxiang 2025-06-03 00:17:03 +08:00
parent d83ea57fca
commit ec6c4cde83
4 changed files with 100 additions and 33 deletions

View File

@ -65,7 +65,7 @@ const McpHubView = () => {
const handleDelete = async (serverName: string) => {
const hub = await getMcpHub();
if (hub) {
if (confirm(`确定要删除服务器 "${serverName}" 吗?`)) {
if (confirm(t('mcpHub.deleteConfirm', { name: serverName }))) {
await hub.deleteServer(serverName, "global")
const updatedServers = hub.getAllServers()
setMcpServers(updatedServers)
@ -76,12 +76,12 @@ const McpHubView = () => {
const handleCreate = async () => {
// 验证输入
if (newServerName.trim().length === 0) {
new Notice("服务器名称不能为空")
new Notice(t('mcpHub.serverNameRequired'))
return
}
if (newServerConfig.trim().length === 0) {
new Notice("配置不能为空")
new Notice(t('mcpHub.configRequired'))
return
}
@ -89,7 +89,7 @@ const McpHubView = () => {
try {
JSON.parse(newServerConfig)
} catch (error) {
new Notice("配置格式无效,请输入有效的 JSON 格式")
new Notice(t('mcpHub.invalidConfig'))
return
}
@ -103,9 +103,9 @@ const McpHubView = () => {
// 清空表单
setNewServerName('')
setNewServerConfig('')
new Notice(`服务器 "${newServerName}" 创建成功`)
new Notice(t('mcpHub.createSuccess', { name: newServerName }))
} catch (error) {
new Notice(`创建服务器失败: ${error.message}`)
new Notice(t('mcpHub.createFailed', { error: error.message }))
}
}
}
@ -144,7 +144,7 @@ const McpHubView = () => {
if (properties && typeof properties === 'object' && Object.keys(properties).length > 0) {
return (
<div className="infio-mcp-tool-parameters">
<h5 className="infio-mcp-parameters-title">{t('parameters')}</h5>
<h5 className="infio-mcp-parameters-title">{t('mcpHub.parameters')}</h5>
{Object.entries(properties).map(
([paramName, paramSchemaUntyped]) => {
const paramSchema = paramSchemaUntyped && typeof paramSchemaUntyped === 'object' ? paramSchemaUntyped : {};
@ -157,7 +157,7 @@ const McpHubView = () => {
{isRequired && <span className="infio-mcp-parameter-required">*</span>}
</code>
<span className="infio-mcp-parameter-description">
{paramDescription || t('mcpHub.tool.noDescription')}
{paramDescription || t('mcpHub.toolNoDescription')}
</span>
</div>
);
@ -198,7 +198,7 @@ const McpHubView = () => {
<div className="infio-mcp-hub-container">
{/* Header Section */}
<div className="infio-mcp-hub-header">
<h2 className="infio-mcp-hub-title">MCP </h2>
<h2 className="infio-mcp-hub-title">{t('mcpHub.title')}</h2>
</div>
{/* MCP Settings */}
@ -211,12 +211,12 @@ const McpHubView = () => {
onChange={switchMcp}
className="infio-mcp-setting-checkbox"
/>
<span className="infio-mcp-setting-text"> MCP </span>
<span className="infio-mcp-setting-text">{t('mcpHub.enableMcp')}</span>
</label>
<p className="infio-mcp-setting-description">
MCP API Token
{t('mcpHub.enableMcpDescription')}
<a href="https://modelcontextprotocol.io/introduction" target="_blank" rel="noopener noreferrer">
Learn more about MCP
{t('mcpHub.learnMore')}
</a>
</p>
</div>
@ -231,33 +231,25 @@ const McpHubView = () => {
<div className="infio-mcp-hub-expander">
{isCreateSectionExpanded ? <ChevronDown size={16} /> : <ChevronRight size={16} />}
</div>
<h3 className="infio-mcp-create-title">+ MCP </h3>
<h3 className="infio-mcp-create-title">{t('mcpHub.addNewServer')}</h3>
</div>
</div>
{isCreateSectionExpanded && (
<div className="infio-mcp-create-expanded">
<div className="infio-mcp-create-label"></div>
<div className="infio-mcp-create-label">{t('mcpHub.serverName')}</div>
<input
type="text"
value={newServerName}
onChange={(e) => setNewServerName(e.target.value)}
placeholder="输入服务器名称"
placeholder={t('mcpHub.serverNamePlaceholder')}
className="infio-mcp-create-input"
/>
<div className="infio-mcp-create-label"> (JSON )</div>
<div className="infio-mcp-create-label">{t('mcpHub.config')}</div>
<textarea
value={newServerConfig}
onChange={(e) => setNewServerConfig(e.target.value)}
placeholder='example: {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}'
placeholder={t('mcpHub.configPlaceholder')}
className="infio-mcp-create-textarea"
rows={4}
/>
@ -266,7 +258,7 @@ const McpHubView = () => {
className="infio-mcp-create-btn"
disabled={!newServerName.trim() || !newServerConfig.trim()}
>
<span></span>
<span>{t('mcpHub.createServer')}</span>
</button>
</div>
)}
@ -296,14 +288,13 @@ const McpHubView = () => {
</div>
<span className={`infio-mcp-hub-status-indicator ${server.status === 'connected' ? 'connected' : server.status === 'connecting' ? 'connecting' : 'disconnected'} ${server.disabled ? 'disabled' : ''}`}></span>
<h3 className="infio-mcp-hub-name">{server.name}</h3>
{/* <span className="infio-mcp-hub-source-badge">{server.source}</span> */}
</div>
<div className="infio-mcp-hub-actions" onClick={(e) => e.stopPropagation()}>
<button
className={`infio-section-btn ${server.disabled ? 'disabled' : 'enabled'}`}
onClick={() => handleToggle(server.name, server.disabled)}
title={server.disabled ? '启用服务器' : '禁用服务器'}
title={server.disabled ? t('mcpHub.enable') : t('mcpHub.disable')}
>
<Power size={16} />
</button>
@ -311,7 +302,7 @@ const McpHubView = () => {
<button
className="infio-section-btn"
onClick={() => handleRestart(server.name)}
title="重启服务器"
title={t('mcpHub.restart')}
>
<RotateCcw size={16} />
</button>
@ -319,7 +310,7 @@ const McpHubView = () => {
<button
className="infio-section-btn"
onClick={() => handleDelete(server.name)}
title="删除服务器"
title={t('mcpHub.delete')}
>
<Trash2 size={16} />
</button>
@ -328,7 +319,11 @@ const McpHubView = () => {
<div className="infio-mcp-hub-status-info">
<span className="infio-mcp-status-text">
: <span className={`status-value ${server.status}`}>{server.status}</span>
{t('mcpHub.status')}: <span className={`status-value ${server.status}`}>
{server.status === 'connected' ? t('mcpHub.statusConnected') :
server.status === 'connecting' ? t('mcpHub.statusConnecting') :
t('mcpHub.statusDisconnected')}
</span>
</span>
</div>
@ -351,7 +346,7 @@ const McpHubView = () => {
{tabName === 'tools' && <Wrench size={14} />}
{tabName === 'resources' && <Folder size={14} />}
{tabName === 'errors' && <AlertTriangle size={14} />}
{t(`${tabName}`)} ({count})
{t(`mcpHub.${tabName}`)} ({count})
</button>
);
})}

View File

@ -361,5 +361,41 @@ export default {
fewShotExamplesDescription: 'The model uses these examples to learn the expected answer format. Not all examples are sent at the same time. We only send the relevant examples, given the current cursor location. For example, the CodeBlock examples are only sent if the cursor is in a code block. If no special context is detected, we send the Text examples. Each context has a default of 2 examples, but you can add or remove examples if there is at least one per context. You can add more examples, but this will increase the inference costs.',
},
}
},
mcpHub: {
title: "MCP Servers",
enableMcp: "Enable MCP Servers",
enableMcpDescription: "Enable to use tools from connected MCP servers for enhanced capabilities. It's recommended to disable when not using these tools to save API token costs.",
learnMore: "Learn more about MCP",
addNewServer: "+ Add New MCP Server",
serverName: "Server Name",
serverNamePlaceholder: "Enter server name",
config: "Configuration (JSON format)",
configPlaceholder: "example: {\n \"command\": \"npx\",\n \"args\": [\n \"-y\",\n \"@modelcontextprotocol/server-filesystem\",\n \"/Users/username/Desktop\",\n \"/path/to/other/allowed/dir\"\n ]\n}",
createServer: "Create Server",
status: "Status",
statusConnected: "Connected",
statusConnecting: "Connecting",
statusDisconnected: "Disconnected",
enable: "Enable Server",
disable: "Disable Server",
restart: "Restart Server",
delete: "Delete Server",
deleteConfirm: "Are you sure you want to delete server \"{name}\"?",
createSuccess: "Server \"{name}\" created successfully",
createFailed: "Failed to create server: {error}",
serverNameRequired: "Server name cannot be empty",
configRequired: "Configuration cannot be empty",
invalidConfig: "Invalid configuration format, please enter valid JSON",
noServersFound: "No servers found",
serverNotConnectedError: "Server is not connected",
tools: "Tools",
resources: "Resources",
errors: "Errors",
noTools: "No tools available",
noResources: "No resources available",
noErrors: "No error records",
parameters: "Parameters",
toolNoDescription: "No description"
}
}

View File

@ -361,6 +361,42 @@ export default {
fewShotExamples: 'Few shot 示例',
fewShotExamplesDescription: '模型使用这些示例来学习预期的答案格式。并非所有示例都同时发送。我们仅根据当前光标位置发送相关示例。例如,仅当光标位于代码块中时才发送 CodeBlock 示例。如果未检测到特殊上下文,则发送 Text 示例。每个上下文默认有 2 个示例,但如果每个上下文至少有一个示例,则可以添加或删除示例。您可以添加更多示例,但这会增加推理成本。',
},
},
mcpHub: {
title: "MCP 服务器",
enableMcp: "启用 MCP 服务器",
enableMcpDescription: "开启后可用已连接 MCP 服务器的工具,能力更强。不用这些工具时建议关闭,节省 API Token 费用。",
learnMore: "了解更多关于 MCP",
addNewServer: "+ 添加新的 MCP 服务器",
serverName: "服务器名称",
serverNamePlaceholder: "输入服务器名称",
config: "配置 (JSON 格式)",
configPlaceholder: "example: {\n \"command\": \"npx\",\n \"args\": [\n \"-y\",\n \"@modelcontextprotocol/server-filesystem\",\n \"/Users/username/Desktop\",\n \"/path/to/other/allowed/dir\"\n ]\n}",
createServer: "创建服务器",
status: "状态",
statusConnected: "已连接",
statusConnecting: "连接中",
statusDisconnected: "未连接",
enable: "启用服务器",
disable: "禁用服务器",
restart: "重启服务器",
delete: "删除服务器",
deleteConfirm: "确定要删除服务器 \"{name}\" 吗?",
createSuccess: "服务器 \"{name}\" 创建成功",
createFailed: "创建服务器失败: {error}",
serverNameRequired: "服务器名称不能为空",
configRequired: "配置不能为空",
invalidConfig: "配置格式无效,请输入有效的 JSON 格式",
noServersFound: "未找到服务器",
serverNotConnectedError: "服务器未连接",
tools: "工具",
resources: "资源",
errors: "错误",
noTools: "没有可用工具",
noResources: "没有可用资源",
noErrors: "没有错误记录",
parameters: "参数",
toolNoDescription: "无描述"
}
}
};

View File

@ -41,7 +41,7 @@ export async function onEnt(
}
const postData = JSON.stringify(payload)
const apiUrl = new URL(`https://api.infio.com/e1/api/event`)
const apiUrl = new URL(`https://hubs.infio.app/e1/api/event`)
const options = {
hostname: apiUrl.hostname,