fix(系统设置): sqlbot设置点击校验会关闭抽屉并保存,但提示没有关于校验的验证信息

This commit is contained in:
dataeaseShu
2025-09-11 17:53:52 +08:00
committed by dataeaseShu
parent 47ac58beba
commit 1e13a6e369
2 changed files with 20 additions and 4 deletions

View File

@@ -110,19 +110,27 @@ const closeLoading = () => {
loadingInstance.value?.close()
}
const validateHandler = () => {
const validateHandlerOnly = () => {
let url = `${
state.form.domain.endsWith('/') ? state.form.domain : state.form.domain + '/'
}api/v1/system/assistant/info/${state.form.id}`
fetch(url)
.then(response => response.json())
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok')
}
return response.json()
})
.then(() => {
state.form.valid = true
ElMessage.success(t('datasource.validate_success'))
})
.catch(() => {
ElMessage.error(t('data_source.verification_failed'))
state.form.enabled = false
state.form.valid = false
})
.finally(() => {
save()
})
}
@@ -158,7 +166,7 @@ defineExpose({
<template #footer>
<span class="dialog-footer">
<el-button @click="resetForm(dingtalkForm)">{{ t('common.cancel') }}</el-button>
<el-button :disabled="!state.form.id || !state.form.domain" @click="validateHandler">
<el-button :disabled="!state.form.id || !state.form.domain" @click="validateHandlerOnly">
{{ t('commons.validate') }}
</el-button>
<el-button type="primary" @click="submitForm(dingtalkForm)">

View File

@@ -67,14 +67,22 @@ const validateHandler = () => {
info.value.domain.endsWith('/') ? info.value.domain : info.value.domain + '/'
}api/v1/system/assistant/info/${info.value.id}`
fetch(url)
.then(response => response.json())
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok')
}
return response.json()
})
.then(() => {
info.value.valid = true
ElMessage.success(t('datasource.validate_success'))
})
.catch(() => {
ElMessage.error(t('data_source.verification_failed'))
info.value.enabled = false
info.value.valid = false
})
.finally(() => {
save()
})
}