feat: 设置信息

This commit is contained in:
jinyaqiu 2025-08-04 20:00:15 +08:00
parent 240601b97b
commit fab73d196f
3 changed files with 80 additions and 71 deletions

View File

@ -11,7 +11,7 @@ import { checkNotificationPermission, getLocationPermission, getPermissions, req
import { ThemedText } from '@/components/ThemedText';
import { useAuth } from '@/contexts/auth-context';
import { fetchApi } from '@/lib/server-api-util';
import { Address } from '@/types/user';
import { Address, User, UserInfoDetails } from '@/types/user';
import * as Location from 'expo-location';
import { useFocusEffect, useRouter } from 'expo-router';
import * as SecureStore from 'expo-secure-store';
@ -20,8 +20,14 @@ import { useTranslation } from 'react-i18next';
import { Linking, Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { useSafeAreaInsets } from "react-native-safe-area-context";
const Setting = (props: { userInfo: any }) => {
const { userInfo } = props;
const Setting = (props: { userInfo: UserInfoDetails }) => {
const [userInfo, setUserInfo] = useState<User | null>(null);
const getUserInfo = async () => {
const res = await fetchApi<User>("/iam/user-info");
setUserInfo(res);
}
const insets = useSafeAreaInsets();
const { t } = useTranslation();
// 判断当前语言环境
@ -200,6 +206,7 @@ const Setting = (props: { userInfo: any }) => {
// 获取语言环境
useEffect(() => {
getLanguage();
getUserInfo()
}, [])
return (
@ -220,7 +227,7 @@ const Setting = (props: { userInfo: any }) => {
<ScrollView style={styles.modalContent} showsVerticalScrollIndicator={false}>
{/* 用户信息 */}
<UserInfo
userInfo={userInfo}
userInfo={userInfo || {} as User}
setCurrentLocation={setCurrentLocation}
getCurrentLocation={getCurrentLocation}
isLoading={isLoading}

View File

@ -20,6 +20,7 @@ export default function Look(props: Props) {
const { fileData, setFileData, isLoading, handleUser, avatar } = props;
const { t } = useTranslation();
return (
<View className="flex-1 bg-textPrimary justify-between p-[2rem]">
<View className="flex-1 justify-center items-center">
@ -32,11 +33,11 @@ export default function Look(props: Props) {
{t('auth.userMessage.avatorText2', { ns: 'login' })}
</ThemedText>
{
fileData[0]?.previewUrl
fileData[0]?.preview || fileData[0]?.previewUrl
?
<Image
className='rounded-full w-[10rem] h-[10rem]'
source={{ uri: fileData[0].previewUrl }}
source={{ uri: fileData[0].preview || fileData[0].previewUrl }}
/>
:
avatar

View File

@ -99,6 +99,7 @@ export interface FileUploadItem {
status: 'pending' | 'uploading' | 'success' | 'error'; // 统一状态
error?: string | null;
previewUrl: string; // 预览URL
preview: string; // 预览URL
file?: File;
type: 'image' | 'video';
thumbnail?: string; // 缩略图URL