import { useEffect, useRef } from 'react' import type { ReactNode } from 'react' import { ChevronDown, Layers, ListVideo } from 'lucide-react' import type { Media } from '../types' import { mediaVersionLabel, mediaVersionMatches } from '../utils/mediaVersion' // PlayerMobileTheaterInfo — 竖屏剧场模式下视频下方的可滚动内容区。 // // 竖屏手机不再用全屏居中黑边布局:视频贴顶按 16:9 自适应高度, // 下面这块区域接管标题、选集、版本切换和简介,信息密度与 // 主流手机视频应用保持一致。桌面端与横屏手机不渲染它。 // // 选集刻意放在这里而不是弹层里:从操作栏点「选集」只做「展开 + 滚到这里」, // 播放画面始终可见,不会像浮层那样盖住正在看的内容。 type PlayerMobileTheaterInfoProps = { media: Media | null title: string subtitle?: string playbackModeLabel?: string qualityLabel?: string episodes: Media[] currentMediaId: string currentEpisodeIndex: number currentVersions?: Media[] onSelectEpisode: (media: Media) => void onSelectVersion?: (media: Media) => void /** 选集列表是否展开(展开后由 playlistPanel 接管,提供季/搜索/版本)。 */ playlistOpen: boolean onTogglePlaylist: () => void /** 展开状态下的选集内容(复用播放器的选集面板,内嵌渲染)。 */ playlistPanel?: ReactNode /** * 每次从操作栏点「选集」都会 +1:即使列表已经展开,也要把这块滚回视野内。 */ revealToken?: number } function episodeShortLabel(ep: Media): string { if (ep.episode_num > 0) return `${ep.episode_num}` const title = ep.episode_title?.trim() || ep.title?.trim() || '' return title ? title.slice(0, 4) : '·' } function episodeFullLabel(ep: Media): string { if (ep.episode_num > 0) { const title = ep.episode_title?.trim() return title && title !== ep.title?.trim() ? `第 ${ep.episode_num} 集 · ${title}` : `第 ${ep.episode_num} 集` } return ep.episode_title?.trim() || ep.title?.trim() || '未命名' } export function PlayerMobileTheaterInfo({ media, title, subtitle, playbackModeLabel, qualityLabel, episodes, currentMediaId, currentEpisodeIndex, currentVersions = [], onSelectEpisode, onSelectVersion, playlistOpen, onTogglePlaylist, playlistPanel, revealToken = 0, }: PlayerMobileTheaterInfoProps) { const episodeSectionRef = useRef(null) const hasEpisodeList = episodes.length > 1 const versionsToSwitch = currentVersions.length > 1 ? currentVersions : [] const overview = media?.overview?.trim() || '' // 从操作栏点「选集」:把选集区滚回视野内,用户不用自己往上翻。 useEffect(() => { if (!revealToken) return episodeSectionRef.current?.scrollIntoView({ block: 'start', behavior: 'smooth' }) }, [revealToken]) return (

{title || '加载中…'}

{subtitle ?

{subtitle}

: null} {(playbackModeLabel || qualityLabel) && (
{qualityLabel ? ( {qualityLabel} ) : null} {playbackModeLabel ? ( {playbackModeLabel} ) : null}
)} {hasEpisodeList ? (

选集 {currentEpisodeIndex >= 0 ? `${currentEpisodeIndex + 1}/${episodes.length}` : `${episodes.length} 集`}

{playlistOpen && playlistPanel ? ( playlistPanel ) : (
{episodes.map((ep) => { const active = mediaVersionMatches(ep, currentMediaId) return ( ) })}
)}
) : null} {/* 多版本切换:展开选集后由选集面板顶部的版本区接管,这里不重复一份 */} {versionsToSwitch.length > 0 && !playlistOpen ? (

版本 {versionsToSwitch.length} 个

{versionsToSwitch.map((version) => { const active = mediaVersionMatches(version, currentMediaId) return ( ) })}
) : null} {overview ? (

简介

{overview}

) : null}

将手机横放可获得全屏沉浸式播放体验

) }