feat: 新增体重记录功能,优化用户资料更新及图片组件缓存
This commit is contained in:
@@ -3,8 +3,7 @@ import { Colors } from '@/constants/Colors';
|
||||
import { useAppDispatch, useAppSelector } from '@/hooks/redux';
|
||||
import { useColorScheme } from '@/hooks/useColorScheme';
|
||||
import { useCosUpload } from '@/hooks/useCosUpload';
|
||||
import { updateUser as updateUserApi } from '@/services/users';
|
||||
import { fetchMyProfile } from '@/store/userSlice';
|
||||
import { fetchMyProfile, updateUserProfile } from '@/store/userSlice';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import DateTimePicker from '@react-native-community/datetimepicker';
|
||||
@@ -175,8 +174,7 @@ export default function EditProfileScreen() {
|
||||
|
||||
// 同步到后端(仅更新后端需要的字段)
|
||||
try {
|
||||
await updateUserApi({
|
||||
userId,
|
||||
await dispatch(updateUserProfile({
|
||||
name: next.name || undefined,
|
||||
gender: (next.gender === 'male' || next.gender === 'female') ? next.gender : undefined,
|
||||
// 头像采用已上传的 URL(若有)
|
||||
@@ -185,7 +183,7 @@ export default function EditProfileScreen() {
|
||||
height: next.height || undefined,
|
||||
birthDate: next.birthDate ? new Date(next.birthDate).getTime() / 1000 : undefined,
|
||||
activityLevel: next.activityLevel || undefined,
|
||||
});
|
||||
}));
|
||||
// 拉取最新用户信息,刷新全局状态
|
||||
await dispatch(fetchMyProfile() as any);
|
||||
} catch (e: any) {
|
||||
|
||||
Reference in New Issue
Block a user