import { Calendar } from 'lucide-react' import type { Media } from '../types' type MediaDetailMetadataProps = { media: Media } export function MediaDetailMetadata({ media }: MediaDetailMetadataProps) { const heading = media.episode_title?.trim() || media.title const showTitleContext = Boolean(media.episode_title?.trim() && media.title && media.title !== heading) const genres = parseCSV(media.genres) const languages = parseCSV(media.languages) const countries = parseCSV(media.countries) const hasTaxonomy = genres.length > 0 || languages.length > 0 || countries.length > 0 return ( <>

{heading}

{showTitleContext && (

{media.title}

)}
{media.year > 0 && ( {media.year} 年 )} {media.width > 0 && media.height > 0 && ( {media.width} × {media.height} )} {media.size_bytes > 0 && ( {fmtSize(media.size_bytes)} )} {media.duration_sec > 0 && ( {fmtDuration(media.duration_sec)} )} {media.container && ( {media.container} )}
{media.overview && (

剧情简介

{media.overview}

)} {hasTaxonomy && (
)} ) } /** * One "label - values" row of the taxonomy block. * * All rows share the same label gutter, so every value column starts on the * same vertical line. Pills keep one geometry and differ by tone only. */ function MetadataRow({ label, values, tone = 'neutral', }: { label: string values: string[] tone?: 'neutral' | 'brand' }) { if (values.length === 0) return null const tagClass = [ 'inline-flex items-center rounded-lg border px-2.5 py-1 text-2xs font-bold uppercase tracking-wide', tone === 'brand' ? 'border-brand-100/50 bg-brand-50 text-brand-700' : 'border-gray-200/60 bg-gray-100 text-gray-600', ].join(' ') return (
{label}
{values.map((value) => ( {value} ))}
) } function fmtDuration(sec: number): string { if (!sec || sec <= 0) return '—' const h = Math.floor(sec / 3600) const m = Math.floor((sec % 3600) / 60) return h > 0 ? `${h}h ${m}m` : `${m}m` } function fmtSize(bytes: number): string { if (!bytes || bytes <= 0) return '—' const units = ['B', 'KB', 'MB', 'GB', 'TB'] let v = bytes let i = 0 while (v >= 1024 && i < units.length - 1) { v /= 1024 i++ } return `${v.toFixed(2)} ${units[i]}` } function parseCSV(s?: string): string[] { if (!s) return [] return s.split(',').map((x) => x.trim()).filter(Boolean) }