-
Notifications
You must be signed in to change notification settings - Fork 3.2k
style: update style for mcp server #8338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -498,7 +498,7 @@ func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error { | |
| } | ||
| websiteID := GetWebsiteID() | ||
| if req.ID == websiteID { | ||
| _ = settingRepo.UpdateOrCreate("MCP_WEBSITE_ID", "0") | ||
| _ = settingRepo.Update("MCP_WEBSITE_ID", "0") | ||
| } | ||
| tx.Commit() | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code has an issue where the parameter Additionally, there's unnecessary use of Here’s a revised version with these adjustments: @@ -498,7 +498,11 @@ func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error {
}
websiteID := GetWebsiteID()
if req.ID == websiteID {
- _ = settingRepo.UpdateOrCreate("MCP_WEBSITE_ID", "0")
+ err := settingRepo.Update("MCP_WEBSITE_ID", "0")
+ if err != nil {
+ return err // Handle the error appropriately
+ }
}
tx.Commit()
Make sure to handle any potential errors from the |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,8 +82,15 @@ | |
| </el-form-item> | ||
| </el-col> | ||
| </el-row> | ||
| <el-form-item :label="$t('mcp.baseUrl')" prop="baseUrl"> | ||
| <el-input v-model.trim="mcpServer.baseUrl"></el-input> | ||
| <el-form-item :label="$t('mcp.baseUrl')" prop="url"> | ||
| <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"> | ||
| {{ $t('mcp.baseUrlHelper') }} | ||
| </span> | ||
|
|
@@ -142,6 +149,8 @@ const newMcpServer = () => { | |
| environments: [], | ||
| volumes: [], | ||
| hostIP: '127.0.0.1', | ||
| protocol: 'http://', | ||
| url: '', | ||
| }; | ||
| }; | ||
| const em = defineEmits(['close']); | ||
|
|
@@ -151,7 +160,7 @@ const rules = ref({ | |
| command: [Rules.requiredInput], | ||
| port: [Rules.requiredInput, Rules.port], | ||
| containerName: [Rules.requiredInput], | ||
| baseUrl: [Rules.requiredInput], | ||
| url: [Rules.requiredInput], | ||
| ssePath: [Rules.requiredInput], | ||
| key: [Rules.requiredInput], | ||
| value: [Rules.requiredInput], | ||
|
|
@@ -167,14 +176,22 @@ const acceptParams = async (params: AI.McpServer) => { | |
| if (!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 { | ||
| mcpServer.value = newMcpServer(); | ||
| if (params.port) { | ||
| mcpServer.value.port = params.port; | ||
| } | ||
| try { | ||
| 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) { | ||
| MsgError(error); | ||
| } | ||
|
|
@@ -229,6 +246,7 @@ const submit = async (formEl: FormInstance | undefined) => { | |
| } | ||
| try { | ||
| loading.value = true; | ||
| mcpServer.value.baseUrl = mcpServer.value.protocol + mcpServer.value.url; | ||
| if (mode.value == 'create') { | ||
| await createMcpServer(mcpServer.value); | ||
| MsgSuccess(i18n.global.t('commons.msg.createSuccess')); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two main changes:
Additionally, this might be affecting form validation rules as well, so you'd need review those too to ensure they account for these new properties. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes made in this code snippet seem appropriate since returning
nilinstead of an error indicates that there was no issue fetching the website record with the provided ID. However, for better readability and maintainability, it's good practice to log errors if they occur. Here's an optimized version:This code includes logging when an error occurs using a package like
log. Additionally, I've used type assertions in the repository call (&res) for explicitness, which might not be necessary in simpler contexts but can enhance clarity.