mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-07 23:18:38 +08:00
- 新增 sentry-react-native、react-native-video、react-native-static-server、expo-network、expo-intent-launcher、expo-clipboard、expo-file-system 的 web shim - 重写 react-native-pager-view shim,通过 useImperativeHandle 暴露 setPage 方法 - 修复 sentry-react-native shim 缺少 ErrorBoundary 导致的渲染崩溃 - 在 _layout.tsx 中加载 Ionicons 字体,修复 web 端字体 404 - 更新 metro.config.js 中 sentry shim 路径为 .tsx
94 lines
2.8 KiB
TypeScript
94 lines
2.8 KiB
TypeScript
import { Stack } from 'expo-router';
|
||
import { StatusBar } from 'expo-status-bar';
|
||
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
||
import { Text, View } from 'react-native';
|
||
import { useEffect } from 'react';
|
||
import { useAuthStore } from '../store/authStore';
|
||
import { useDownloadStore } from '../store/downloadStore';
|
||
import { useSettingsStore } from '../store/settingsStore';
|
||
import { MiniPlayer } from '../components/MiniPlayer';
|
||
import * as Sentry from '@sentry/react-native';
|
||
import { ErrorBoundary } from '@sentry/react-native';
|
||
import { useFonts } from 'expo-font';
|
||
import { Ionicons } from '@expo/vector-icons';
|
||
|
||
Sentry.init({
|
||
dsn: process.env.EXPO_PUBLIC_SENTRY_DSN ?? '',
|
||
enabled: !__DEV__,
|
||
tracesSampleRate: 0.05,
|
||
environment: process.env.EXPO_PUBLIC_APP_ENV ?? 'production',
|
||
});
|
||
|
||
function RootLayout() {
|
||
const restore = useAuthStore(s => s.restore);
|
||
const loadDownloads = useDownloadStore(s => s.loadFromStorage);
|
||
const restoreSettings = useSettingsStore(s => s.restore);
|
||
|
||
const [fontsLoaded] = useFonts({
|
||
...Ionicons.font,
|
||
});
|
||
|
||
useEffect(() => {
|
||
restore();
|
||
loadDownloads();
|
||
restoreSettings();
|
||
}, []);
|
||
|
||
if (!fontsLoaded) return null;
|
||
|
||
return (
|
||
<SafeAreaProvider>
|
||
<StatusBar style="dark" />
|
||
<View style={{ flex: 1 }}>
|
||
<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>
|
||
<MiniPlayer />
|
||
</View>
|
||
</SafeAreaProvider>
|
||
);
|
||
}
|
||
|
||
export default Sentry.wrap(RootLayout);
|