mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-08 07:28:37 +08:00
- 新增 store/liveStore.ts:Zustand store,存储小窗直播状态(roomId/title/cover/hlsUrl) - 新增 components/LiveMiniPlayer.tsx:可拖动悬浮迷你直播播放器 - 原生端实际播放 HLS 流(react-native-video,有声) - Web 端降级展示封面图 + LIVE 徽标 - LIVE 红点徽标 + 标题条底部 - 关闭按钮(×)和点击进入直播间 - HLS 出错时自动关闭(onError → clearLive) - 视频 MiniPlayer 激活时自动上移避免重叠 - _layout.tsx:全局挂载 <LiveMiniPlayer /> - live/[roomId].tsx:顶部栏添加小窗按钮(browsers-outline) - 仅直播中且有流地址时显示,离线时占位保持 title 居中 - 点击后 setLive + router.back(),返回首页继续看直播 - 进入同房间时自动 clearLive() 避免双播
91 lines
2.8 KiB
TypeScript
91 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 { useTheme } from '../utils/theme';
|
||
import { MiniPlayer } from '../components/MiniPlayer';
|
||
import { LiveMiniPlayer } from '../components/LiveMiniPlayer';
|
||
import * as Sentry from '@sentry/react-native';
|
||
import { ErrorBoundary } from '@sentry/react-native';
|
||
|
||
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 darkMode = useSettingsStore(s => s.darkMode);
|
||
|
||
useEffect(() => {
|
||
restore();
|
||
loadDownloads();
|
||
restoreSettings();
|
||
|
||
}, []);
|
||
|
||
return (
|
||
<SafeAreaProvider>
|
||
<StatusBar style={darkMode ? 'light' : '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 />
|
||
<LiveMiniPlayer />
|
||
</View>
|
||
</SafeAreaProvider>
|
||
);
|
||
}
|
||
|
||
export default Sentry.wrap(RootLayout);
|