Skip to content

Commit

Permalink
docs: settings save success
Browse files Browse the repository at this point in the history
  • Loading branch information
ZonaHex committed Dec 26, 2024
1 parent dbc811a commit d77af3a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/components/global-setting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ a-drawer.settings-drawer(
span.bold {{ ` US/Pacific. ` }}
| See more at
a-link(icon href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones" target="_blank") Wiki.
a-form-item
a-form-item.save
a-button(
type="primary"
long
:loading="loginLoading"
@click="save"
) {{ $t('settings.save') }}
template(#extra)
span.fail(v-if="!loginSuccess") {{ $t('settings.saveTip') }}
span.danger-color(v-if="loginStatus === 'fail'") {{ $t('settings.saveTip') }}
span.success-color(v-if="loginStatus === 'success'")
icon-check-circle
| {{ $t('settings.saveSuccess') }}
</template>

<script lang="ts" setup name="GlobalSetting">
Expand All @@ -69,7 +72,7 @@ a-drawer.settings-drawer(
const { role } = storeToRefs(useUserStore())
const { globalSettings, host, database, username, password, databaseList, userTimezone } = storeToRefs(useAppStore())
const loginSuccess = ref(true)
const loginStatus = ref('')
const loginLoading = ref(false)
const settingsForm = ref({
Expand All @@ -87,10 +90,17 @@ a-drawer.settings-drawer(
axios.defaults.baseURL = settingsForm.value.host
loginLoading.value = true
loginSuccess.value = await login(settingsForm.value)
if (loginSuccess.value) {
updateSettings({ globalSettings: false })
const res = await login(settingsForm.value)
if (res) {
loginStatus.value = 'success'
checkTables()
setTimeout(() => {
updateSettings({
globalSettings: false,
})
}, 2000)
} else {
loginStatus.value = 'fail'
}
loginLoading.value = false
}
Expand All @@ -109,6 +119,7 @@ a-drawer.settings-drawer(
database: database.value,
userTimezone: userTimezone.value,
}
loginStatus.value = ''
}
})
Expand Down Expand Up @@ -148,6 +159,11 @@ a-drawer.settings-drawer(
}
.arco-form-item {
margin-bottom: 10px;
&.save {
.arco-form-item-extra {
font-size: 12px;
}
}
}
.arco-drawer-header {
display: none;
Expand All @@ -156,16 +172,6 @@ a-drawer.settings-drawer(
.arco-drawer-body {
padding: 16px 16px 10px 16px;
}
.save {
.arco-form-item {
margin-bottom: 0;
}
}
.fail {
color: var(--danger-color);
}
}
.bold {
font-weight: 600;
Expand Down
1 change: 1 addition & 0 deletions src/locale/en-US/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export default {
'settings.username': 'Username',
'settings.timezone': 'Timezone',
'settings.saveTip': 'Authentication failed. Please check your settings.',
'settings.saveSuccess': 'Success!',
}
1 change: 1 addition & 0 deletions src/locale/zh-CN/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export default {
'settings.save': '保存',
'settings.timezone': '时区',
'settings.saveTip': '认证失败,请检查您的设置。',
'settings.saveSuccess': '保存成功!',
}

0 comments on commit d77af3a

Please sign in to comment.