chore: enhance error handling in McpToolFormDrawer
--bug=1062456 --user=刘瑞斌 【工具】新建MCP,配置信息不合规,报错提示不对 https://www.tapd.cn/62980211/s/1781971v3.2
parent
36636f2707
commit
9f73eb0aa2
|
|
@ -119,7 +119,7 @@ import { computed, reactive, ref, watch } from 'vue'
|
||||||
import EditAvatarDialog from '@/views/tool/component/EditAvatarDialog.vue'
|
import EditAvatarDialog from '@/views/tool/component/EditAvatarDialog.vue'
|
||||||
import type { toolData } from '@/api/type/tool'
|
import type { toolData } from '@/api/type/tool'
|
||||||
import type { FormInstance } from 'element-plus'
|
import type { FormInstance } from 'element-plus'
|
||||||
import { MsgConfirm, MsgSuccess } from '@/utils/message'
|
import { MsgConfirm, MsgError, MsgSuccess } from '@/utils/message'
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
import { isAppIcon } from '@/utils/common'
|
import { isAppIcon } from '@/utils/common'
|
||||||
|
|
@ -245,9 +245,16 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
await formEl.validate((valid: any) => {
|
await formEl.validate((valid: any) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
try {
|
||||||
|
JSON.parse(form.value.code as string)
|
||||||
|
} catch (e) {
|
||||||
|
MsgError(t('views.applicationWorkflow.nodes.mcpNode.mcpServerTip'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
loading.value = true
|
||||||
if (isEdit.value) {
|
if (isEdit.value) {
|
||||||
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
||||||
.putTool(form.value?.id as string, form.value, loading)
|
.putTool(form.value?.id as string, form.value)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
MsgSuccess(t('common.editSuccess'))
|
MsgSuccess(t('common.editSuccess'))
|
||||||
emit('refresh', res.data)
|
emit('refresh', res.data)
|
||||||
|
|
@ -256,13 +263,16 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
visible.value = false
|
visible.value = false
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
const obj = {
|
const obj = {
|
||||||
folder_id: folder.currentFolder?.id,
|
folder_id: folder.currentFolder?.id,
|
||||||
...form.value,
|
...form.value,
|
||||||
}
|
}
|
||||||
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
||||||
.postTool(obj, loading)
|
.postTool(obj)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
MsgSuccess(t('common.createSuccess'))
|
MsgSuccess(t('common.createSuccess'))
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
|
|
@ -271,6 +281,9 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
visible.value = false
|
visible.value = false
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue