From 0c55231788b4412d12436b2d5c6293ed2a9a8453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=E9=AD=8F?= Date: Sat, 23 Aug 2025 14:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BF=80=E6=B4=BB=E5=AF=86=E9=92=A5=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E7=AA=97=E5=8F=A3=EF=BC=8C=E5=85=BC=E5=AE=B9=E8=80=81?= =?UTF-8?q?=E7=9A=84=E5=9B=BD=E9=99=85=E5=8C=96=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/paths/mcp.ts | 5 +- src/components/commonFooter/CommonFooter.vue | 28 +++- src/i18n/index.ts | 14 +- src/i18n/lang/en.ts | 1 + src/i18n/lang/zh-cn.ts | 1 + src/views/api/components/ActiveModel.vue | 146 ++++++++++++++++++ src/views/api/index.vue | 68 ++++++-- .../createapp/components/AgentAppConfig.vue | 2 +- src/views/createapp/components/McpDrawer.vue | 80 ++++++++-- 9 files changed, 315 insertions(+), 30 deletions(-) create mode 100644 src/views/api/components/ActiveModel.vue diff --git a/src/apis/paths/mcp.ts b/src/apis/paths/mcp.ts index c85d8390..19313797 100644 --- a/src/apis/paths/mcp.ts +++ b/src/apis/paths/mcp.ts @@ -84,8 +84,9 @@ const deleteMcpService = (id: string) => { return del<{ serviceId: string }>(`${MCP_BASE_URL}/${id}`); }; -const activeMcpService = (id: string, active: boolean) => { - return post<{ serviceId: string }>(`${MCP_BASE_URL}/${id}`, { active }); +const activeMcpService = (id: string, active: boolean, mcpEnv?: any) => { + return post<{ serviceId: string }>(`${MCP_BASE_URL}/${id}`, { active, mcpEnv }, + { 'Content-Type': 'multipart/form-data' },); }; const installMcpService = (id: string) => { diff --git a/src/components/commonFooter/CommonFooter.vue b/src/components/commonFooter/CommonFooter.vue index b88448ba..48979905 100644 --- a/src/components/commonFooter/CommonFooter.vue +++ b/src/components/commonFooter/CommonFooter.vue @@ -8,12 +8,33 @@ const agreeDialogVisiable = ref(false); // 协议内容 const agreement = ref(''); const policy = ref(''); + +/** + * 获取当前语言 + */ +const getLocale = () => { + const localLang = localStorage.getItem('copilot_language'); + let locale = 'zh'; // 默认值 + + if (localLang) { + try { + const parsed = JSON.parse(localLang); + // 处理可能的 language 值:zh, zh_cn, zh-tw 等 + if (parsed.language) { + locale = parsed.language.startsWith('zh') ? 'zh' : parsed.language; + } + } catch (e) { + console.error('解析语言设置失败:', e); + } + } + return locale; +}; + /** * 读取协议 */ const readAgreement = async () => { - const localLang = localStorage.getItem('copilot_language'); - const locale = (localLang && JSON.parse(localLang).language) || 'zh'; + const locale = getLocale(); const response = locale === 'en' ? await import('src/conf/agreement-en.md?raw') @@ -23,8 +44,7 @@ const readAgreement = async () => { }; const readPolicy = async () => { - const localLang = localStorage.getItem('copilot_language'); - const locale = (localLang && JSON.parse(localLang).language) || 'zh'; + const locale = getLocale(); const response = locale === 'en' ? await import('src/conf/policy-en.md?raw') diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 7fe3eb0f..e830bea8 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -4,7 +4,19 @@ import zh from './lang/zh-cn'; import en from './lang/en'; const localLang = localStorage.getItem('copilot_language'); -const locale = (localLang && JSON.parse(localLang).language) || 'zh'; +let locale = 'zh'; // 默认值 + +if (localLang) { + try { + const parsed = JSON.parse(localLang); + // 处理可能的 language 值:zh, zh_cn, zh-tw 等 + if (parsed.language) { + locale = parsed.language.startsWith('zh') ? 'zh' : parsed.language; + } + } catch (e) { + console.error('解析语言设置失败:', e); + } +} const i18n = createI18n({ legacy: false, // 设置为 false,启用 composition API 模式 diff --git a/src/i18n/lang/en.ts b/src/i18n/lang/en.ts index dad069f3..5adcf021 100644 --- a/src/i18n/lang/en.ts +++ b/src/i18n/lang/en.ts @@ -113,6 +113,7 @@ export default { installed: 'Installed', not_active: 'Not Active', active: 'Active', + active_mcp_service: 'Active MCP Service', }, upload_icon: 'Upload Icon', please_upload_icon: 'Upload an icon.', diff --git a/src/i18n/lang/zh-cn.ts b/src/i18n/lang/zh-cn.ts index 1e4eb871..c729f327 100644 --- a/src/i18n/lang/zh-cn.ts +++ b/src/i18n/lang/zh-cn.ts @@ -113,6 +113,7 @@ export default { installed: '已安装', not_active: '未激活', active: '已激活', + active_mcp_service: '激活MCP服务', }, upload_icon: '上传图标', please_upload_icon: '请上传图标', diff --git a/src/views/api/components/ActiveModel.vue b/src/views/api/components/ActiveModel.vue new file mode 100644 index 00000000..e71f9b18 --- /dev/null +++ b/src/views/api/components/ActiveModel.vue @@ -0,0 +1,146 @@ + + + + diff --git a/src/views/api/index.vue b/src/views/api/index.vue index 00c3a330..c313e5ba 100644 --- a/src/views/api/index.vue +++ b/src/views/api/index.vue @@ -223,15 +223,18 @@ v-if=" (userinfo.user_sub === item.author && pluginType === 'semantic_interface') || - (userinfo.is_admin && pluginType === 'mcp') + pluginType === 'mcp' " class="deleteAndEdit" > {{ item.isActive @@ -260,7 +261,10 @@ {{ $t('semantic.cancel') }} @@ -355,6 +363,12 @@ @change="handleChangePage" /> + +