feat:添加哨兵功能,错误日志收集,为持续迭代做准备

This commit is contained in:
Developer
2026-03-24 00:17:43 +08:00
parent e05484bba6
commit 9bffc16fef
10 changed files with 588 additions and 56 deletions

View File

@@ -1,14 +1,24 @@
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { View } from 'react-native';
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 Updates from 'expo-updates';
import * as Sentry from '@sentry/react-native';
import { ErrorBoundary } from '@sentry/react-native';
export default function RootLayout() {
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);
@@ -17,56 +27,73 @@ export default function RootLayout() {
restore();
loadDownloads();
restoreSettings();
const checkOTA = async () => {
if (!Updates.isEnabled) return;
try {
const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) {
await Updates.fetchUpdateAsync();
}
} catch {
// 静默失败,不影响正常使用
}
};
checkOTA();
}, []);
return (
<SafeAreaProvider>
<StatusBar style="dark" />
<View style={{ flex: 1 }}>
<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 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);