feat(i18n): 实现用户语言偏好服务器同步功能

- 添加 UserLanguage 类型定义 ('zh-CN' | 'en-US')
- 在 UpdateUserDto 中新增 language 字段
- 实现语言切换时自动同步到服务器
- 为已登录用户保存语言偏好设置
- 服务器同步失败时降级处理,不影响本地语言切换
This commit is contained in:
richarjiang
2025-11-27 11:17:21 +08:00
parent 18d83091a9
commit 08adf0f20d
2 changed files with 26 additions and 1 deletions

View File

@@ -2,6 +2,9 @@ import { api } from '@/services/api';
export type Gender = 'male' | 'female';
// 用户语言设置
export type UserLanguage = 'zh-CN' | 'en-US';
export type UpdateUserDto = {
name?: string;
avatar?: string; // base64 字符串
@@ -21,6 +24,7 @@ export type UpdateUserDto = {
armCircumference?: number; // 臂围
thighCircumference?: number; // 大腿围
calfCircumference?: number; // 小腿围
language?: UserLanguage; // 用户语言偏好
};
export async function updateUser(dto: UpdateUserDto): Promise<Record<string, any>> {