mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
chore: enhance error handling in McpToolFormDrawer
--bug=1062456 --user=刘瑞斌 【工具】新建MCP,配置信息不合规,报错提示不对 https://www.tapd.cn/62980211/s/1781971
This commit is contained in:
parent
36636f2707
commit
9f73eb0aa2
|
|
@ -119,7 +119,7 @@ import { computed, reactive, ref, watch } from 'vue'
|
|||
import EditAvatarDialog from '@/views/tool/component/EditAvatarDialog.vue'
|
||||
import type { toolData } from '@/api/type/tool'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { MsgConfirm, MsgSuccess } from '@/utils/message'
|
||||
import { MsgConfirm, MsgError, MsgSuccess } from '@/utils/message'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { t } from '@/locales'
|
||||
import { isAppIcon } from '@/utils/common'
|
||||
|
|
@ -245,9 +245,16 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
if (!formEl) return
|
||||
await formEl.validate((valid: any) => {
|
||||
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) {
|
||||
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) => {
|
||||
MsgSuccess(t('common.editSuccess'))
|
||||
emit('refresh', res.data)
|
||||
|
|
@ -256,13 +263,16 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
.then(() => {
|
||||
visible.value = false
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
} else {
|
||||
const obj = {
|
||||
folder_id: folder.currentFolder?.id,
|
||||
...form.value,
|
||||
}
|
||||
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
||||
.postTool(obj, loading)
|
||||
.postTool(obj)
|
||||
.then((res: any) => {
|
||||
MsgSuccess(t('common.createSuccess'))
|
||||
emit('refresh')
|
||||
|
|
@ -271,6 +281,9 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
.then(() => {
|
||||
visible.value = false
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue