2026-03-10 19:04:18 +08:00
|
|
|
|
import { Stack } from 'expo-router';
|
2026-03-05 18:02:54 +08:00
|
|
|
|
import { StatusBar } from 'expo-status-bar';
|
2026-03-06 12:58:41 +08:00
|
|
|
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
2026-03-24 00:17:43 +08:00
|
|
|
|
import { Text, View } from 'react-native';
|
2026-03-05 18:02:54 +08:00
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
|
|
import { useAuthStore } from '../store/authStore';
|
2026-03-17 22:18:05 +08:00
|
|
|
|
import { useDownloadStore } from '../store/downloadStore';
|
2026-03-19 16:34:56 +08:00
|
|
|
|
import { useSettingsStore } from '../store/settingsStore';
|
2026-03-24 21:04:10 +08:00
|
|
|
|
import { useTheme } from '../utils/theme';
|
2026-03-10 19:04:18 +08:00
|
|
|
|
import { MiniPlayer } from '../components/MiniPlayer';
|
2026-03-24 00:17:43 +08:00
|
|
|
|
import * as Sentry from '@sentry/react-native';
|
|
|
|
|
|
import { ErrorBoundary } from '@sentry/react-native';
|
2026-03-05 18:02:54 +08:00
|
|
|
|
|
2026-03-24 00:17:43 +08:00
|
|
|
|
Sentry.init({
|
|
|
|
|
|
dsn: process.env.EXPO_PUBLIC_SENTRY_DSN ?? '',
|
|
|
|
|
|
enabled: !__DEV__,
|
|
|
|
|
|
tracesSampleRate: 0.05,
|
|
|
|
|
|
environment: process.env.EXPO_PUBLIC_APP_ENV ?? 'production',
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function RootLayout() {
|
2026-03-05 18:02:54 +08:00
|
|
|
|
const restore = useAuthStore(s => s.restore);
|
2026-03-17 22:18:05 +08:00
|
|
|
|
const loadDownloads = useDownloadStore(s => s.loadFromStorage);
|
2026-03-19 16:34:56 +08:00
|
|
|
|
const restoreSettings = useSettingsStore(s => s.restore);
|
2026-03-24 21:04:10 +08:00
|
|
|
|
const darkMode = useSettingsStore(s => s.darkMode);
|
2026-03-05 18:02:54 +08:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
restore();
|
2026-03-17 22:18:05 +08:00
|
|
|
|
loadDownloads();
|
2026-03-19 16:34:56 +08:00
|
|
|
|
restoreSettings();
|
2026-03-24 00:17:43 +08:00
|
|
|
|
|
2026-03-05 18:02:54 +08:00
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2026-03-06 12:58:41 +08:00
|
|
|
|
<SafeAreaProvider>
|
2026-03-24 21:04:10 +08:00
|
|
|
|
<StatusBar style={darkMode ? 'light' : 'dark'} />
|
2026-03-10 19:04:18 +08:00
|
|
|
|
<View style={{ flex: 1 }}>
|
2026-03-24 00:17:43 +08:00
|
|
|
|
<ErrorBoundary fallback={<Text style={{ padding: 32, textAlign: 'center' }}>发生错误,请重启 App</Text>}>
|
|
|
|
|
|
<Stack screenOptions={{ headerShown: false }}>
|
|
|
|
|
|
<Stack.Screen name="index" />
|
|
|
|
|
|
<Stack.Screen
|
|
|
|
|
|
name="video"
|
|
|
|
|
|
options={{
|
|
|
|
|
|
animation: "slide_from_right",
|
|
|
|
|
|
gestureEnabled: true,
|
|
|
|
|
|
gestureDirection: "horizontal",
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Stack.Screen
|
|
|
|
|
|
name="live"
|
|
|
|
|
|
options={{
|
|
|
|
|
|
animation: "slide_from_right",
|
|
|
|
|
|
gestureEnabled: true,
|
|
|
|
|
|
gestureDirection: "horizontal",
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Stack.Screen
|
|
|
|
|
|
name="search"
|
|
|
|
|
|
options={{
|
|
|
|
|
|
animation: "slide_from_right",
|
|
|
|
|
|
gestureEnabled: true,
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Stack.Screen
|
|
|
|
|
|
name="downloads"
|
|
|
|
|
|
options={{
|
|
|
|
|
|
animation: "slide_from_right",
|
|
|
|
|
|
gestureEnabled: true,
|
|
|
|
|
|
gestureDirection: "horizontal",
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Stack.Screen
|
|
|
|
|
|
name="settings"
|
|
|
|
|
|
options={{
|
|
|
|
|
|
animation: "slide_from_right",
|
|
|
|
|
|
gestureEnabled: true,
|
|
|
|
|
|
gestureDirection: "horizontal",
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Stack>
|
|
|
|
|
|
</ErrorBoundary>
|
2026-03-10 19:04:18 +08:00
|
|
|
|
<MiniPlayer />
|
|
|
|
|
|
</View>
|
2026-03-06 12:58:41 +08:00
|
|
|
|
</SafeAreaProvider>
|
2026-03-05 18:02:54 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-03-24 00:17:43 +08:00
|
|
|
|
|
|
|
|
|
|
export default Sentry.wrap(RootLayout);
|