Skip to content

Commit 9f73eb0

Browse files
committed
chore: enhance error handling in McpToolFormDrawer
--bug=1062456 --user=刘瑞斌 【工具】新建MCP,配置信息不合规,报错提示不对 https://www.tapd.cn/62980211/s/1781971
1 parent 36636f2 commit 9f73eb0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ui/src/views/tool/McpToolFormDrawer.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ import { computed, reactive, ref, watch } from 'vue'
119119
import EditAvatarDialog from '@/views/tool/component/EditAvatarDialog.vue'
120120
import type { toolData } from '@/api/type/tool'
121121
import type { FormInstance } from 'element-plus'
122-
import { MsgConfirm, MsgSuccess } from '@/utils/message'
122+
import { MsgConfirm, MsgError, MsgSuccess } from '@/utils/message'
123123
import { cloneDeep } from 'lodash'
124124
import { t } from '@/locales'
125125
import { isAppIcon } from '@/utils/common'
@@ -245,9 +245,16 @@ const submit = async (formEl: FormInstance | undefined) => {
245245
if (!formEl) return
246246
await formEl.validate((valid: any) => {
247247
if (valid) {
248+
try {
249+
JSON.parse(form.value.code as string)
250+
} catch (e) {
251+
MsgError(t('views.applicationWorkflow.nodes.mcpNode.mcpServerTip'))
252+
return
253+
}
254+
loading.value = true
248255
if (isEdit.value) {
249256
loadSharedApi({ type: 'tool', systemType: apiType.value })
250-
.putTool(form.value?.id as string, form.value, loading)
257+
.putTool(form.value?.id as string, form.value)
251258
.then((res: any) => {
252259
MsgSuccess(t('common.editSuccess'))
253260
emit('refresh', res.data)
@@ -256,13 +263,16 @@ const submit = async (formEl: FormInstance | undefined) => {
256263
.then(() => {
257264
visible.value = false
258265
})
266+
.finally(() => {
267+
loading.value = false
268+
})
259269
} else {
260270
const obj = {
261271
folder_id: folder.currentFolder?.id,
262272
...form.value,
263273
}
264274
loadSharedApi({ type: 'tool', systemType: apiType.value })
265-
.postTool(obj, loading)
275+
.postTool(obj)
266276
.then((res: any) => {
267277
MsgSuccess(t('common.createSuccess'))
268278
emit('refresh')
@@ -271,6 +281,9 @@ const submit = async (formEl: FormInstance | undefined) => {
271281
.then(() => {
272282
visible.value = false
273283
})
284+
.finally(() => {
285+
loading.value = false
286+
})
274287
}
275288
}
276289
})

0 commit comments

Comments
 (0)