fix: test connection status may display incorrectly #79

This commit is contained in:
Lykin 2023-11-21 17:39:04 +08:00
parent 7b18ed0b26
commit 9aaf32e2bf
1 changed files with 6 additions and 6 deletions

View File

@ -120,8 +120,10 @@ const onLoadSentinelMasters = async () => {
const tab = ref('general') const tab = ref('general')
const testing = ref(false) const testing = ref(false)
const showTestResult = ref(false) const testResult = ref(null)
const testResult = ref('') const showTestResult = computed(() => {
return !testing.value && testResult.value != null
})
const predefineColors = ref(['', '#F75B52', '#F7A234', '#F7CE33', '#4ECF60', '#348CF7', '#B270D3']) const predefineColors = ref(['', '#F75B52', '#F7A234', '#F7CE33', '#4ECF60', '#348CF7', '#B270D3'])
const generalFormRef = ref(null) const generalFormRef = ref(null)
const advanceFormRef = ref(null) const advanceFormRef = ref(null)
@ -194,8 +196,7 @@ const resetForm = () => {
generalForm.value = connectionStore.newDefaultConnection() generalForm.value = connectionStore.newDefaultConnection()
generalFormRef.value?.restoreValidation() generalFormRef.value?.restoreValidation()
testing.value = false testing.value = false
showTestResult.value = false testResult.value = null
testResult.value = ''
tab.value = 'general' tab.value = 'general'
loadingSentinelMaster.value = false loadingSentinelMaster.value = false
} }
@ -226,7 +227,6 @@ const onTestConnection = async () => {
result = e.message result = e.message
} finally { } finally {
testing.value = false testing.value = false
showTestResult.value = true
} }
if (!isEmpty(result)) { if (!isEmpty(result)) {
@ -566,7 +566,7 @@ const onClose = () => {
<!-- test result alert--> <!-- test result alert-->
<n-alert <n-alert
v-if="showTestResult" v-if="showTestResult"
:on-close="() => (showTestResult = false)" :on-close="() => (testResult = '')"
:title="isEmpty(testResult) ? '' : $t('dialogue.connection.test_fail')" :title="isEmpty(testResult) ? '' : $t('dialogue.connection.test_fail')"
:type="isEmpty(testResult) ? 'success' : 'error'" :type="isEmpty(testResult) ? 'success' : 'error'"
closable> closable>