-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: add warn text for mcp server #8346
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 |
|---|---|---|
|
|
@@ -101,7 +101,7 @@ import McpServerOperate from './operate/index.vue'; | |
| import ComposeLogs from '@/components/compose-log/index.vue'; | ||
| import { GlobalStore } from '@/store'; | ||
| import i18n from '@/lang'; | ||
| import { MsgError, MsgSuccess } from '@/utils/message'; | ||
| import { MsgSuccess } from '@/utils/message'; | ||
| import BindDomain from './bind/index.vue'; | ||
| import Config from './config/index.vue'; | ||
| const globalStore = GlobalStore(); | ||
|
|
@@ -193,7 +193,7 @@ const openDetail = (row: AI.McpServer) => { | |
| }; | ||
|
|
||
| const openCreate = () => { | ||
| let maxPort = 8000; | ||
| let maxPort = 7999; | ||
| if (items.value && items.value.length > 0) { | ||
| maxPort = Math.max(...items.value.map((item) => item.port)); | ||
| } | ||
|
|
@@ -216,9 +216,7 @@ const deleteServer = async (row: AI.McpServer) => { | |
| api: deleteMcpServer, | ||
| params: { id: row.id }, | ||
| }); | ||
| } catch (error) { | ||
| MsgError(error); | ||
| } | ||
| } catch (error) {} | ||
| }; | ||
|
|
||
| const opServer = async (row: AI.McpServer, operate: string) => { | ||
|
|
@@ -235,9 +233,7 @@ const opServer = async (row: AI.McpServer, operate: string) => { | |
| await operateMcpServer({ id: row.id, operate: operate }); | ||
| MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); | ||
| search(); | ||
| } catch (error) { | ||
| MsgError(error); | ||
| } | ||
| } catch (error) {} | ||
| }); | ||
| }; | ||
|
|
||
|
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 a few minor changes and corrections in the provided code snippet that might be worth noting:
Here's a slightly refined version of the code with some comments for clarity: // Import necessary components and utilities
import McpServerOperate from './operate/index.vue';
import ComposeLogs from '@/components/compose-log/index.vue';
import { GlobalStore } from '@/store';
import i18n from '@/lang';
import { MsgSuccess } from '@/utils/message'; // Consistent import
import BindDomain from './bind/index.vue';
import Config from './config/index.vue';
const globalStore = GlobalStore();
/**
* Opens the detail view for a specific MC Server
* @param {AI.McpServer} row - Data associated with the server
*/
const openDetail = (row: AI.McpServer) => {};
/**
* Opens the create server form
*/
const openCreate = () => {
const maxPort = items.value ? Math.max(...items.value.map(item => item.port)) : 7999; // Use default value
};
/**
* Deletes a specified MCC Server
* @param {AI.McpServer} row - Data associated with the server to be deleted
*/
const deleteServer = async (row: AI.McpServer) => {
try {
await api.deleteMcpServer({ id: row.id });
} catch (error) {} // Handle error silently for now
};
/**
* Performs a operation on a specific MCC Server
* @param {AI.McpServer} row - Data associated with the server
* @param {string} operate - Type of operation ('create', 'update', etc.)
*/
const opServer = async (row: AI.McpServer, operate: string) => {
try {
await operateMcpServer({ id: row.id, operate: operate });
MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); // Show success message only upon successful completion
search(); // Always execute search after operation successfully completed
} catch (error) {}
};Summary of Changes and Improvements:
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,7 +67,7 @@ | |
| </div> | ||
| <Volumes :volumes="mcpServer.volumes" class="mb-2" /> | ||
| <el-row :gutter="20"> | ||
| <el-col :span="6"> | ||
| <el-col :span="8"> | ||
| <el-form-item :label="$t('commons.table.port')" prop="port"> | ||
| <el-input v-model.number="mcpServer.port" /> | ||
| </el-form-item> | ||
|
|
@@ -124,7 +124,7 @@ import { AI } from '@/api/interface/ai'; | |
| import { createMcpServer, getMcpDomain, updateMcpServer } from '@/api/modules/ai'; | ||
| import { Rules } from '@/global/form-rules'; | ||
| import i18n from '@/lang'; | ||
| import { MsgError, MsgSuccess } from '@/utils/message'; | ||
| import { MsgSuccess } from '@/utils/message'; | ||
| import { FormInstance } from 'element-plus'; | ||
| import { ref, watch } from 'vue'; | ||
| import Volumes from '../volume/index.vue'; | ||
|
|
@@ -195,9 +195,7 @@ const acceptParams = async (params: AI.McpServer) => { | |
| mcpServer.value.baseUrl = res.data.connUrl; | ||
| hasWebsite.value = true; | ||
| } | ||
| } catch (error) { | ||
| MsgError(error); | ||
| } | ||
| } catch (error) {} | ||
| } | ||
| open.value = true; | ||
| }; | ||
|
|
@@ -248,7 +246,7 @@ const submit = async (formEl: FormInstance | undefined) => { | |
| return; | ||
| } | ||
| let request = true; | ||
| if (!hasWebsite.value) { | ||
| if (mcpServer.value.hostIP != '0.0.0.0' && !hasWebsite.value) { | ||
| await ElMessageBox.confirm(i18n.global.t('app.installWarn'), i18n.global.t('app.checkTitle'), { | ||
| confirmButtonText: i18n.global.t('commons.button.confirm'), | ||
| cancelButtonText: i18n.global.t('commons.button.cancel'), | ||
|
|
@@ -270,8 +268,6 @@ const submit = async (formEl: FormInstance | undefined) => { | |
| MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); | ||
| } | ||
| handleClose(); | ||
| } catch (error) { | ||
| MsgError(error); | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
|
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 changes have a few potential issues:
Optimizations and Recommendations
Here's revised versions based on these recommendations: const submit = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
let request = true;
+ // Check if website needs to be checked before submitting updates
if (mcpServer.value.hostIP != '0.0.0.0' || hasWebsite.value == false) {
await ElMessageBox.confirm(i18n.global.t('app.installWarn'), i18n.global.t('app.checkTitle'), {
showCancelButton: true,
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),
}).catch(() => {
// Cancel action
});ConclusionThese changes enhance code readability by adding comments and ensuring consistent behavior across different parts of the form submission process. |
||
|
|
||
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.
These changes look mostly appropriate:
The addition of
server.HostIP = "127.0.0.1";is valid, assuming this is intended to set the host IP address for each server.No critical errors appear from these changes.
The overall logic and flow seems coherent.
However, it's worth noting that setting the host IP statically might be more challenging in a production environment where different servers would need distinct IPs or configurations. If you want to ensure consistency across all proxies, you may consider generating dynamic IPs based on some rules or using existing configuration files.
As per your suggestion to check the code periodically for updates and improvements, I recommend automating this process with tools like GitHub Actions or GitLab Pipelines if necessary. This could include running linter checks (e.g., GoLint) after every commit, updating tests as needed, and performing unit/integration tests automatically whenever changes are pushed to the repository.
For further development guidance on best practices around network configurations within larger systems such as web services and load balancers, please let me know, and I can provide additional insights!