From f16be7f49e34944b66904f7f153075ff4e51d95e Mon Sep 17 00:00:00 2001 From: Hu Gang <18768366022@163.com> Date: Wed, 30 Apr 2025 17:18:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/paths/api.ts | 25 +- src/apis/paths/index.ts | 2 + src/apis/paths/mcp.ts | 70 ++++ src/views/api/components/McpDrawer.vue | 280 ++++++++++++++++ src/views/api/components/McpServiceDetail.vue | 314 ++++++++++++++++++ src/views/api/components/MonacoEditor.vue | 90 +++++ src/views/api/components/PluginCard.vue | 85 +++++ src/views/api/style.scss | 79 ++--- 8 files changed, 883 insertions(+), 62 deletions(-) create mode 100644 src/apis/paths/mcp.ts create mode 100644 src/views/api/components/McpDrawer.vue create mode 100644 src/views/api/components/McpServiceDetail.vue create mode 100644 src/views/api/components/MonacoEditor.vue create mode 100644 src/views/api/components/PluginCard.vue diff --git a/src/apis/paths/api.ts b/src/apis/paths/api.ts index 96c5d1db..95dd5fae 100644 --- a/src/apis/paths/api.ts +++ b/src/apis/paths/api.ts @@ -10,7 +10,26 @@ import { QueryApiListParamsType, CreateOrUpdateApiParamsType } from './type'; // 导出一个函数queryApiList,用于查询API列表 export const queryApiList = ( params: QueryApiListParamsType, -): Promise<[any, FcResponse | undefined]> => { +): Promise< + [ + any, + ( + | FcResponse<{ + totalCount: number; + currentPage: number; + services: { + serviceId: string; + description: string; + favorited: boolean; + icon: string; + author: string; + name: string; + }[]; + }> + | undefined + ), + ] +> => { // 调用get函数,传入/api/service路径和params参数,返回一个Promise对象 return get('/api/service', params); }; @@ -34,7 +53,9 @@ export const createOrUpdateApi = ( export const querySingleApiData = (params: { serviceId: string; edit?: boolean; -}): Promise<[any, FcResponse | undefined]> => { +}): Promise< + [any, FcResponse<{ data: any; name: string; apis: string }> | undefined] +> => { return get(`/api/service/${params.serviceId}`, { edit: params.edit }); }; diff --git a/src/apis/paths/index.ts b/src/apis/paths/index.ts index f87c8a52..786e662d 100644 --- a/src/apis/paths/index.ts +++ b/src/apis/paths/index.ts @@ -14,3 +14,5 @@ export * from './apikey'; export * from './knowledge'; export * from './app'; export * from './api'; +export * from './model'; +export * from './mcp'; diff --git a/src/apis/paths/mcp.ts b/src/apis/paths/mcp.ts new file mode 100644 index 00000000..bf0b67ec --- /dev/null +++ b/src/apis/paths/mcp.ts @@ -0,0 +1,70 @@ +import { get, post, del } from '../server'; + +const MCP_BASE_URL = '/api/mcpservice'; +/** + * 获取用户的模型列表 + * @returns + */ +const getMcpList = (params: { + searchType: string; + keyword: string; + page: number; + pageSize: number; +}) => { + return get<{ + currentPage: number; + totalCount: 0; + services: [ + { + mcpserviceId: string; + name: string; + description: string; + icon: string; + author: string; + }, + ]; + totalModels: number; + }>(MCP_BASE_URL, params); +}; + +const getMcpServiceDetail = (mcpserviceId: string) => { + return get<{ + serviceId: string; + icon: string; + name: string; + description: string; + data: { + transmitProto: 'Stdio' | 'Streamable' | 'SSE'; + config: string; + }; + tools: { + name: string; + description: string; + input_args: { + name: string; + description: string; + type: string; + }[]; + output_args: { + name: string; + description: string; + type: string; + }[]; + }[]; + }>(`${MCP_BASE_URL}/${mcpserviceId}`); +}; + +const createMcpService = (params: { + icon: string; + name: string; + description: string; + config: { transmitProto: 'Stdio' | 'Streamable' | 'SSE'; config: string }; +}) => { + return post<{}>(`${MCP_BASE_URL}`, params); +}; + +export const mcpApi = { + getMcpList, + getMcpServiceDetail, + createMcpService, +}; diff --git a/src/views/api/components/McpDrawer.vue b/src/views/api/components/McpDrawer.vue new file mode 100644 index 00000000..15b8646a --- /dev/null +++ b/src/views/api/components/McpDrawer.vue @@ -0,0 +1,280 @@ + + + diff --git a/src/views/api/components/McpServiceDetail.vue b/src/views/api/components/McpServiceDetail.vue new file mode 100644 index 00000000..e0088155 --- /dev/null +++ b/src/views/api/components/McpServiceDetail.vue @@ -0,0 +1,314 @@ + + + diff --git a/src/views/api/components/MonacoEditor.vue b/src/views/api/components/MonacoEditor.vue new file mode 100644 index 00000000..ae400ba4 --- /dev/null +++ b/src/views/api/components/MonacoEditor.vue @@ -0,0 +1,90 @@ + + + diff --git a/src/views/api/components/PluginCard.vue b/src/views/api/components/PluginCard.vue new file mode 100644 index 00000000..a504f634 --- /dev/null +++ b/src/views/api/components/PluginCard.vue @@ -0,0 +1,85 @@ + + + diff --git a/src/views/api/style.scss b/src/views/api/style.scss index 12a46734..fb4c0923 100644 --- a/src/views/api/style.scss +++ b/src/views/api/style.scss @@ -30,14 +30,14 @@ } .createApi { - margin-left: 16px; + margin-left: 8px; border-radius: 4px; } + } .apiCenterType { display: flex; - width: 400px; height: 32px; align-items: center; justify-content: space-between; @@ -45,7 +45,7 @@ border-radius: 4px; background-color: var(--o-border-color-base); .apiCenterBtn { - width: 130px; + width: 197px; height: 28px; display: flex; font-size: 12px; @@ -57,8 +57,6 @@ } } .apiCenterCardContainer { - margin-top: 12px; - padding-top: 4px; max-width: 1336px; max-height: calc(100vh - 370px); min-height: calc(100vh - 370px); @@ -70,6 +68,7 @@ flex-wrap: wrap; box-sizing: border-box; gap: 16px; + margin-top: 16px; .apiCenterCardSingle { box-sizing: border-box; border: 1px solid transparent; @@ -82,64 +81,24 @@ height: 136px; padding: 16px; background-color: var(--o-bg-color-base); - .apiCenterCardTop { + .apiCenterCardContentCollect { + width: 24px; + height: 24px; + background-color: var(--o-bg-color-light); + border-radius: 8px; display: flex; - .apiCenterCardIcon { - margin-right: 18px; - display: flex; - align-items: center; - .menu-icon { - width: 48px; - height: 48px; + justify-content: center; + align-items: center; + svg { + width: 16px; + height: 16px; + path { + fill: var(--o-text-color-tertiary); } } - .apiCenterCardContent { - cursor: pointer; - flex: 1; - display: flex; - flex-direction: column; - gap: 4px; - .apiCenterCardContentTop { - display: flex; - justify-content: space-between; - .apiCenterCardContentTitle { - color: var(--o-text-color-primary); - font-size: 16px; - line-height: 24px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - width: 80%; - } - .apiCenterCardContentCollect { - width: 24px; - height: 24px; - background-color: var(--o-bg-color-light); - border-radius: 8px; - display: flex; - justify-content: center; - align-items: center; - svg { - width: 16px; - height: 16px; - path { - fill: var(--o-text-color-tertiary); - } - } - .apiFavorite { - path { - fill: rgb(99, 149, 253); - } - } - } - } - .apiCenterCardContentDes { - .vue-text{ - cursor: pointer !important; - color: var(--o-api-description); - } - font-size: 14px; - line-height: 22px; + .apiFavorite { + path { + fill: rgb(99, 149, 253); } } } -- Gitee