Compare commits
3 Commits
main
...
fix/https_
| Author | SHA1 | Date | |
|---|---|---|---|
| 2331b05db4 | |||
| 0061a655ef | |||
| 683df4a7c1 |
4
app.json
4
app.json
@ -93,8 +93,8 @@
|
|||||||
"typedRoutes": true
|
"typedRoutes": true
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"API_ENDPOINT": "http://192.168.31.16:31646/api",
|
"API_ENDPOINT": "http://192.168.31.154:8080/api",
|
||||||
"WEBSOCKET_ENDPOINT": "ws://192.168.31.16:31646/ws/chat",
|
"WEBSOCKET_ENDPOINT": "ws://192.168.31.154:8080/ws/chat",
|
||||||
"router": {},
|
"router": {},
|
||||||
"eas": {
|
"eas": {
|
||||||
"projectId": "04721dd4-6b15-495a-b9ec-98187c613172"
|
"projectId": "04721dd4-6b15-495a-b9ec-98187c613172"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Asset } from 'expo-asset';
|
import { Asset } from 'expo-asset';
|
||||||
import { useRouter } from 'expo-router';
|
import { useLocalSearchParams, useRouter } from 'expo-router';
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { FlatList, InteractionManager, PixelRatio, Platform, RefreshControl, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
import { FlatList, InteractionManager, PixelRatio, Platform, RefreshControl, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
||||||
@ -48,6 +48,16 @@ const MemoList = () => {
|
|||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const flatListRef = useRef<FlatList>(null);
|
const flatListRef = useRef<FlatList>(null);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { next } = useLocalSearchParams<{ next: string }>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (next) {
|
||||||
|
// 使用 InteractionManager 确保在动画和交互完成后执行
|
||||||
|
InteractionManager.runAfterInteractions(() => {
|
||||||
|
router.replace(next as any);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [next, router]);
|
||||||
|
|
||||||
// 从缓存或API获取数据
|
// 从缓存或API获取数据
|
||||||
const fetchHistoryList = useCallback(async (forceRefresh = false) => {
|
const fetchHistoryList = useCallback(async (forceRefresh = false) => {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ export default function UserMessage() {
|
|||||||
// 获取路由参数
|
// 获取路由参数
|
||||||
const params = useLocalSearchParams();
|
const params = useLocalSearchParams();
|
||||||
const { username: usernameParam } = params;
|
const { username: usernameParam } = params;
|
||||||
|
const { from } = useLocalSearchParams<{ from?: string }>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
checkAuthStatus(router);
|
checkAuthStatus(router);
|
||||||
@ -47,11 +48,17 @@ export default function UserMessage() {
|
|||||||
})
|
})
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setSteps('done');
|
if (from) {
|
||||||
}).catch(() => {
|
router.replace(from as any);
|
||||||
|
} else {
|
||||||
|
router.replace('/ask');
|
||||||
|
}
|
||||||
|
}).catch((error: any) => {
|
||||||
|
console.error('Failed to save user info:', error);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getUserInfo();
|
getUserInfo();
|
||||||
setSteps("userName")
|
setSteps("userName")
|
||||||
|
|||||||
@ -47,12 +47,16 @@ const Login = ({ updateUrlParam, setError, setShowPassword, showPassword }: Logi
|
|||||||
login({ ...res, email: res?.account }, res.access_token || '');
|
login({ ...res, email: res?.account }, res.access_token || '');
|
||||||
const userInfo = await fetchApi<User>("/iam/user-info");
|
const userInfo = await fetchApi<User>("/iam/user-info");
|
||||||
if (userInfo?.nickname) {
|
if (userInfo?.nickname) {
|
||||||
router.replace('/ask');
|
router.replace({ pathname: '/memo-list', params: { next: '/ask' } });
|
||||||
} else {
|
} else {
|
||||||
router.replace('/user-message');
|
router.replace({ pathname: '/user-message', params: { from: '/memo-list' } });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error.message || t('auth.login.loginError', { ns: 'login' }));
|
if (error instanceof Error) {
|
||||||
|
setError(error.message);
|
||||||
|
} else {
|
||||||
|
setError(String(error) || t('auth.login.loginError', { ns: 'login' }));
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user