fix: application set language error

This commit is contained in:
wxg0103 2025-02-13 11:44:52 +08:00 committed by wxg
parent c59a19bbcb
commit 20260df9a1
2 changed files with 6 additions and 8 deletions

View File

@ -374,6 +374,8 @@ class ApplicationSerializer(serializers.Serializer):
application_access_token.show_source = instance.get('show_source') application_access_token.show_source = instance.get('show_source')
if 'language' in instance and instance.get('language') is not None: if 'language' in instance and instance.get('language') is not None:
application_access_token.language = instance.get('language') application_access_token.language = instance.get('language')
if 'language' not in instance or instance.get('language') is None:
application_access_token.language = None
application_access_token.save() application_access_token.save()
application_setting_model = DBModelManage.get_model('application_setting') application_setting_model = DBModelManage.get_model('application_setting')
xpack_cache = DBModelManage.get_model('xpack_cache') xpack_cache = DBModelManage.get_model('xpack_cache')

View File

@ -60,7 +60,7 @@ const emit = defineEmits(['refresh'])
const displayFormRef = ref() const displayFormRef = ref()
const form = ref<any>({ const form = ref<any>({
show_source: false, show_source: false,
language: '', language: ''
}) })
const detail = ref<any>(null) const detail = ref<any>(null)
@ -72,14 +72,14 @@ watch(dialogVisible, (bool) => {
if (!bool) { if (!bool) {
form.value = { form.value = {
show_source: false, show_source: false,
language: '', language: ''
} }
} }
}) })
const open = (data: any, content: any) => { const open = (data: any, content: any) => {
detail.value = content detail.value = content
form.value.show_source = data.show_source form.value.show_source = data.show_source
form.value.language = data.language || getBrowserLang() form.value.language = data.language
dialogVisible.value = true dialogVisible.value = true
} }
@ -87,11 +87,7 @@ const submit = async (formEl: FormInstance | undefined) => {
if (!formEl) return if (!formEl) return
await formEl.validate((valid, fields) => { await formEl.validate((valid, fields) => {
if (valid) { if (valid) {
const obj = { applicationApi.putAccessToken(id as string, form.value, loading).then((res) => {
show_source: form.value.show_source,
language: form.value.language
}
applicationApi.putAccessToken(id as string, obj, loading).then((res) => {
emit('refresh') emit('refresh')
// @ts-ignore // @ts-ignore
MsgSuccess(t('common.settingSuccess')) MsgSuccess(t('common.settingSuccess'))