mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 06:55:57 +08:00
Fix language setting not success (#5023)
This commit is contained in:
parent
3b60c28b3a
commit
ea5c8a72e2
@ -22,27 +22,41 @@ export default function LanguagePage() {
|
|||||||
const { notify } = useContext(ToastContext)
|
const { notify } = useContext(ToastContext)
|
||||||
const [editing, setEditing] = useState(false)
|
const [editing, setEditing] = useState(false)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const handleSelect = async (type: string, item: Item) => {
|
|
||||||
let url = ''
|
const handleSelectLanguage = async (item: Item) => {
|
||||||
let bodyKey = ''
|
const url = '/account/interface-language'
|
||||||
if (type === 'language') {
|
const bodyKey = 'interface_language'
|
||||||
url = '/account/interface-language'
|
|
||||||
bodyKey = 'interface_language'
|
|
||||||
setLocaleOnClient(item.value.toString())
|
|
||||||
}
|
|
||||||
if (type === 'timezone') {
|
|
||||||
url = '/account/timezone'
|
|
||||||
bodyKey = 'timezone'
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
setEditing(true)
|
setEditing(true)
|
||||||
|
try {
|
||||||
await updateUserProfile({ url, body: { [bodyKey]: item.value } })
|
await updateUserProfile({ url, body: { [bodyKey]: item.value } })
|
||||||
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
||||||
mutateUserProfile()
|
|
||||||
setEditing(false)
|
setLocaleOnClient(item.value.toString())
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
notify({ type: 'error', message: (e as Error).message })
|
notify({ type: 'error', message: (e as Error).message })
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
setEditing(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSelectTimezone = async (item: Item) => {
|
||||||
|
const url = '/account/timezone'
|
||||||
|
const bodyKey = 'timezone'
|
||||||
|
|
||||||
|
setEditing(true)
|
||||||
|
try {
|
||||||
|
await updateUserProfile({ url, body: { [bodyKey]: item.value } })
|
||||||
|
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
||||||
|
|
||||||
|
mutateUserProfile()
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
notify({ type: 'error', message: (e as Error).message })
|
||||||
|
}
|
||||||
|
finally {
|
||||||
setEditing(false)
|
setEditing(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,7 +68,7 @@ export default function LanguagePage() {
|
|||||||
<SimpleSelect
|
<SimpleSelect
|
||||||
defaultValue={locale || userProfile.interface_language}
|
defaultValue={locale || userProfile.interface_language}
|
||||||
items={languages.filter(item => item.supported)}
|
items={languages.filter(item => item.supported)}
|
||||||
onSelect={item => handleSelect('language', item)}
|
onSelect={item => handleSelectLanguage(item)}
|
||||||
disabled={editing}
|
disabled={editing}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -63,7 +77,7 @@ export default function LanguagePage() {
|
|||||||
<SimpleSelect
|
<SimpleSelect
|
||||||
defaultValue={userProfile.timezone}
|
defaultValue={userProfile.timezone}
|
||||||
items={timezones}
|
items={timezones}
|
||||||
onSelect={item => handleSelect('timezone', item)}
|
onSelect={item => handleSelectTimezone(item)}
|
||||||
disabled={editing}
|
disabled={editing}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user