fix:修复

This commit is contained in:
吕新雨
2026-02-05 16:06:49 +08:00
parent 2b67a571bb
commit 8e71503169
18 changed files with 924 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
import { SafeAreaView } from 'react-native-safe-area-context';
import { setConsentAccepted, getConsentAccepted } from '../../src/storage/appStorage';
import { fetchLegalLinks } from '@/src/services/legalApi';
import { getOnboardingCompleted } from '@/src/storage/appStorage';
// 导入 SVG 组件
import FlowersBg from '../../assets/images/index/flowers_endbg.svg';
@@ -27,7 +28,13 @@ export default function SplashScreen() {
const accepted = await getConsentAccepted();
setShowConsent(!accepted);
if (accepted) {
router.replace('/');
// 已同意协议则直接分发到目标页,避免先回到 /index再二次跳转导致“闪一下”
const completed = await getOnboardingCompleted();
if (completed) {
router.replace('/(app)/home');
} else {
router.replace('/(onboarding)/onboarding');
}
}
};

View File

@@ -32,7 +32,8 @@ export {
export const unstable_settings = {
// Ensure that reloading on `/modal` keeps a back button present.
initialRouteName: 'index',
// 让首次启动(未同意协议)直接进入协议页,避免先渲染 index 再跳转导致“闪一下”
initialRouteName: '(splash)/splash',
};
// Prevent the splash screen from auto-hiding before asset loading is complete.
@@ -144,6 +145,9 @@ function RootLayoutNav() {
return (
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<Stack screenOptions={{ headerShown: false }}>
{/* 协议页分组(首次启动优先进入) */}
<Stack.Screen name="(splash)" />
{/* 启动分发页:根据 onboarding 状态跳转 */}
<Stack.Screen name="index" />
@@ -173,7 +177,8 @@ const styles = StyleSheet.create({
backgroundColor: '#EAD2BA',
},
splashImage: {
width: '80%',
height: '80%',
// 覆盖层图片尺寸需与系统原生 Splash 的视觉一致,避免出现“缩小一下”的错觉
width: '100%',
height: '100%',
},
});