'use client'; import { Monitor, MonitorPlay, Users } from 'lucide-react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { useEffect } from 'react'; import { useWatchRoomContext } from '@/components/WatchRoomProvider'; import { useScreenShare } from '@/hooks/useScreenShare'; const NEW_TAB_KEY_PREFIX = 'watch_room_screen_home_opened_'; export default function WatchRoomScreenPage() { const router = useRouter(); const watchRoom = useWatchRoomContext(); const { currentRoom, members, leaveRoom } = watchRoom; const { currentRoom: screenRoom, isOwner, isSharing, isStarting, error, localVideoRef, remoteVideoRef, startSharing, stopSharing, } = useScreenShare(); useEffect(() => { if (!currentRoom) { router.replace('/watch-room'); return; } if (currentRoom.roomType !== 'screen') { router.replace('/watch-room'); } }, [currentRoom, router]); useEffect(() => { if (!screenRoom || !isOwner) return; const key = `${NEW_TAB_KEY_PREFIX}${screenRoom.id}`; if (sessionStorage.getItem(key)) return; sessionStorage.setItem(key, '1'); window.open('/?watchRoomNoConnect=1', '_blank', 'noopener,noreferrer'); }, [isOwner, screenRoom?.id]); if (!screenRoom || screenRoom.roomType !== 'screen') { return null; } const handleLeave = () => { if (isOwner && isSharing) { stopSharing(true); } leaveRoom(); router.push('/watch-room'); }; return (

屏幕共享观影室

房间:{screenRoom.name} · 房主:{screenRoom.ownerName}

{isOwner && ( 新开主页 )}
{isOwner ? (

共享状态

类型:屏幕共享

状态:{isSharing ? '共享中' : '未开始'}

成员:{members.length} 人

{error && (
{error}
)}
{isOwner ? ( <> ) : (
房员无需操作,房主开始共享后会自动显示画面。
)}

房间成员

{members.map((member) => (
{member.name} {member.isOwner && ( 房主 )}
))}
本页不再包裹站点导航,便于直接共享。建议使用桌面版 Chrome / Edge,并优先共享标签页。
); }