style: update style for mcp server (#8338)
Some checks are pending
SonarCloud Scan / SonarCloud (push) Waiting to run

This commit is contained in:
zhengkunwang 2025-04-07 19:09:51 +08:00 committed by GitHub
parent 3be3bf9926
commit 097a33c68f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 34 additions and 14 deletions

View file

@ -238,7 +238,7 @@ func (m McpServerService) GetBindDomain() (response.McpBindDomainRes, error) {
} }
website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteID)) website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteID))
if err != nil { if err != nil {
return res, err return res, nil
} }
res.WebsiteID = website.ID res.WebsiteID = website.ID
res.Domain = website.PrimaryDomain res.Domain = website.PrimaryDomain

View file

@ -498,7 +498,7 @@ func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error {
} }
websiteID := GetWebsiteID() websiteID := GetWebsiteID()
if req.ID == websiteID { if req.ID == websiteID {
_ = settingRepo.UpdateOrCreate("MCP_WEBSITE_ID", "0") _ = settingRepo.Update("MCP_WEBSITE_ID", "0")
} }
tx.Commit() tx.Commit()

View file

@ -135,6 +135,8 @@ export namespace AI {
volumes: Volume[]; volumes: Volume[];
dir?: string; dir?: string;
hostIP: string; hostIP: string;
protocol: string;
url: string;
} }
export interface McpServerSearch extends ReqPage { export interface McpServerSearch extends ReqPage {

View file

@ -2609,7 +2609,7 @@ const message = {
edit: 'Edit MCP Server', edit: 'Edit MCP Server',
commandHelper: 'For example: npx -y {0}', commandHelper: 'For example: npx -y {0}',
baseUrl: 'External Access Path', baseUrl: 'External Access Path',
baseUrlHelper: 'For example: https://127.0.0.1:8080', baseUrlHelper: 'For example: http://192.168.1.2:8000',
ssePath: 'SSE Path', ssePath: 'SSE Path',
ssePathHelper: 'For example: /sse, note not to duplicate with other servers', ssePathHelper: 'For example: /sse, note not to duplicate with other servers',
environment: 'Environment Variables', environment: 'Environment Variables',

View file

@ -2579,7 +2579,7 @@ const message = {
edit: 'サーバーを編集', edit: 'サーバーを編集',
commandHelper: ': npx -y {0}', commandHelper: ': npx -y {0}',
baseUrl: '外部アクセスパス', baseUrl: '外部アクセスパス',
baseUrlHelper: ': https://127.0.0.1:8080', baseUrlHelper: ': http://192.168.1.2:8000',
ssePath: 'SSE パス', ssePath: 'SSE パス',
ssePathHelper: ': /sse, 他のサーバーと重複しないように注意してください', ssePathHelper: ': /sse, 他のサーバーと重複しないように注意してください',
environment: '環境変数', environment: '環境変数',

View file

@ -2538,7 +2538,7 @@ const message = {
edit: 'サーバーを編集', edit: 'サーバーを編集',
commandHelper: ': npx -y {0}', commandHelper: ': npx -y {0}',
baseUrl: '外部アクセスパス', baseUrl: '外部アクセスパス',
baseUrlHelper: ': https://127.0.0.1:8080', baseUrlHelper: ': http://192.168.1.2:8000',
ssePath: 'SSE パス', ssePath: 'SSE パス',
ssePathHelper: ': /sse, 他のサーバーと重複しないように注意してください', ssePathHelper: ': /sse, 他のサーバーと重複しないように注意してください',
environment: '環境変数', environment: '環境変数',

View file

@ -2637,7 +2637,7 @@ const message = {
edit: 'Edit Pelayan', edit: 'Edit Pelayan',
commandHelper: 'Contoh: npx -y {0}', commandHelper: 'Contoh: npx -y {0}',
baseUrl: 'Laluan Akses Luar', baseUrl: 'Laluan Akses Luar',
baseUrlHelper: 'Contoh: https://127.0.0.1:8080', baseUrlHelper: 'Contoh: http://192.168.1.2:8000',
ssePath: 'Laluan SSE', ssePath: 'Laluan SSE',
ssePathHelper: 'Contoh: /sse, berhati-hati jangan bertindan dengan pelayan lain', ssePathHelper: 'Contoh: /sse, berhati-hati jangan bertindan dengan pelayan lain',
environment: 'Pemboleh Ubah Persekitaran', environment: 'Pemboleh Ubah Persekitaran',

View file

@ -2635,7 +2635,7 @@ const message = {
edit: 'Editar Servidor', edit: 'Editar Servidor',
commandHelper: 'Por exemplo: npx -y {0}', commandHelper: 'Por exemplo: npx -y {0}',
baseUrl: 'Caminho de Acesso Externo', baseUrl: 'Caminho de Acesso Externo',
baseUrlHelper: 'Por exemplo: https://127.0.0.1:8080', baseUrlHelper: 'Por exemplo: http://192.168.1.2:8000',
ssePath: 'Caminho SSE', ssePath: 'Caminho SSE',
ssePathHelper: 'Por exemplo: /sse, tome cuidado para não duplicar com outros servidores', ssePathHelper: 'Por exemplo: /sse, tome cuidado para não duplicar com outros servidores',
environment: 'Variáveis de Ambiente', environment: 'Variáveis de Ambiente',

View file

@ -2631,7 +2631,7 @@ const message = {
edit: 'Редактировать сервер', edit: 'Редактировать сервер',
commandHelper: 'Например: npx -y {0}', commandHelper: 'Например: npx -y {0}',
baseUrl: 'Внешний путь доступа', baseUrl: 'Внешний путь доступа',
baseUrlHelper: 'Например: https://127.0.0.1:8080', baseUrlHelper: 'Например: http://192.168.1.2:8000',
ssePath: 'Путь SSE', ssePath: 'Путь SSE',
ssePathHelper: 'Например: /sse, будьте осторожны, чтобы не дублировать с другими серверами', ssePathHelper: 'Например: /sse, будьте осторожны, чтобы не дублировать с другими серверами',
environment: 'Переменные среды', environment: 'Переменные среды',

View file

@ -2444,7 +2444,7 @@ const message = {
edit: '編輯 MCP Server', edit: '編輯 MCP Server',
commandHelper: '例如npx -y {0}', commandHelper: '例如npx -y {0}',
baseUrl: '外部訪問路徑', baseUrl: '外部訪問路徑',
baseUrlHelper: '例如https://127.0.0.1:8080', baseUrlHelper: '例如http://192.168.1.2:8000',
ssePath: 'SSE 路徑', ssePath: 'SSE 路徑',
ssePathHelper: '例如/sse,注意不要與其他 Server 重複', ssePathHelper: '例如/sse,注意不要與其他 Server 重複',
environment: '環境變數', environment: '環境變數',

View file

@ -2446,7 +2446,7 @@ const message = {
edit: '编辑 MCP Server', edit: '编辑 MCP Server',
commandHelper: '例如npx -y {0}', commandHelper: '例如npx -y {0}',
baseUrl: '外部访问路径', baseUrl: '外部访问路径',
baseUrlHelper: '例如https://127.0.0.1:8080', baseUrlHelper: '例如http://192.168.1.1:8000',
ssePath: 'SSE 路径', ssePath: 'SSE 路径',
ssePathHelper: '例如/sse,注意不要与其他 Server 重复', ssePathHelper: '例如/sse,注意不要与其他 Server 重复',
environment: '环境变量', environment: '环境变量',

View file

@ -82,8 +82,15 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item :label="$t('mcp.baseUrl')" prop="baseUrl"> <el-form-item :label="$t('mcp.baseUrl')" prop="url">
<el-input v-model.trim="mcpServer.baseUrl"></el-input> <el-input v-model.trim="mcpServer.url">
<template #prepend>
<el-select v-model="mcpServer.protocol" class="pre-select">
<el-option label="http" value="http://" />
<el-option label="https" value="https://" />
</el-select>
</template>
</el-input>
<span class="input-help"> <span class="input-help">
{{ $t('mcp.baseUrlHelper') }} {{ $t('mcp.baseUrlHelper') }}
</span> </span>
@ -142,6 +149,8 @@ const newMcpServer = () => {
environments: [], environments: [],
volumes: [], volumes: [],
hostIP: '127.0.0.1', hostIP: '127.0.0.1',
protocol: 'http://',
url: '',
}; };
}; };
const em = defineEmits(['close']); const em = defineEmits(['close']);
@ -151,7 +160,7 @@ const rules = ref({
command: [Rules.requiredInput], command: [Rules.requiredInput],
port: [Rules.requiredInput, Rules.port], port: [Rules.requiredInput, Rules.port],
containerName: [Rules.requiredInput], containerName: [Rules.requiredInput],
baseUrl: [Rules.requiredInput], url: [Rules.requiredInput],
ssePath: [Rules.requiredInput], ssePath: [Rules.requiredInput],
key: [Rules.requiredInput], key: [Rules.requiredInput],
value: [Rules.requiredInput], value: [Rules.requiredInput],
@ -167,6 +176,9 @@ const acceptParams = async (params: AI.McpServer) => {
if (!mcpServer.value.volumes) { if (!mcpServer.value.volumes) {
mcpServer.value.volumes = []; mcpServer.value.volumes = [];
} }
const parts = mcpServer.value.baseUrl.split(/(https?:\/\/)/).filter(Boolean);
mcpServer.value.protocol = parts[0];
mcpServer.value.url = parts[1];
} else { } else {
mcpServer.value = newMcpServer(); mcpServer.value = newMcpServer();
if (params.port) { if (params.port) {
@ -174,7 +186,12 @@ const acceptParams = async (params: AI.McpServer) => {
} }
try { try {
const res = await getMcpDomain(); const res = await getMcpDomain();
mcpServer.value.baseUrl = res.data.connUrl; if (res.data.connUrl != '') {
const parts = res.data.connUrl.split(/(https?:\/\/)/).filter(Boolean);
mcpServer.value.protocol = parts[0];
mcpServer.value.url = parts[1];
mcpServer.value.baseUrl = res.data.connUrl;
}
} catch (error) { } catch (error) {
MsgError(error); MsgError(error);
} }
@ -229,6 +246,7 @@ const submit = async (formEl: FormInstance | undefined) => {
} }
try { try {
loading.value = true; loading.value = true;
mcpServer.value.baseUrl = mcpServer.value.protocol + mcpServer.value.url;
if (mode.value == 'create') { if (mode.value == 'create') {
await createMcpServer(mcpServer.value); await createMcpServer(mcpServer.value);
MsgSuccess(i18n.global.t('commons.msg.createSuccess')); MsgSuccess(i18n.global.t('commons.msg.createSuccess'));