Skip to content

Commit c39d7a4

Browse files
committed
fix: improve formatting and add JSON validation in McpServersDialog
--bug=1060753 --user=刘瑞斌 【应用】AI对话节点的MCP使用自定义方式,配置格式错误依然可以保存成功 https://www.tapd.cn/62980211/s/1760128
1 parent 1e05eb1 commit c39d7a4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

ui/src/views/application/component/McpServersDialog.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
>
5050
<div class="flex align-center">
5151
<el-avatar shape="square" :size="20" class="mr-8">
52-
<img src="@/assets/workflow/icon_mcp.svg" style="width: 75%" alt="" />
52+
<img src="@/assets/workflow/icon_mcp.svg" style="width: 75%" alt=""/>
5353
</el-avatar>
5454
<span>{{ mcpTool.name }}</span>
5555
<el-tag v-if="mcpTool.scope === 'SHARED'" type="info" class="info-tag ml-8 mt-4">
@@ -96,9 +96,9 @@
9696
</el-dialog>
9797
</template>
9898
<script setup lang="ts">
99-
import { computed, inject, onMounted, ref, watch } from 'vue'
100-
import { loadSharedApi } from '@/utils/dynamics-api/shared-api.ts'
101-
import { useRoute } from 'vue-router'
99+
import {ref, watch} from 'vue'
100+
import {MsgError} from "@/utils/message.ts";
101+
import {t} from "@/locales";
102102
103103
const emit = defineEmits(['refresh'])
104104
@@ -144,7 +144,7 @@ function mcpSourceChange() {
144144
145145
146146
const open = (data: any, selectOptions: any) => {
147-
form.value = { ...form.value, ...data }
147+
form.value = {...form.value, ...data}
148148
form.value.mcp_source = data.mcp_source || 'referencing'
149149
dialogVisible.value = true
150150
mcpToolSelectOptions.value = selectOptions || []
@@ -153,12 +153,18 @@ const open = (data: any, selectOptions: any) => {
153153
const submit = () => {
154154
paramFormRef.value.validate((valid: any) => {
155155
if (valid) {
156+
try {
157+
JSON.parse(form.value.mcp_servers)
158+
} catch (e) {
159+
MsgError(t('views.applicationWorkflow.nodes.mcpNode.mcpServerTip'))
160+
return
161+
}
156162
emit('refresh', form.value)
157163
dialogVisible.value = false
158164
}
159165
})
160166
}
161167
162-
defineExpose({ open })
168+
defineExpose({open})
163169
</script>
164170
<style lang="scss" scoped></style>

0 commit comments

Comments
 (0)