import { AlertTriangle, RefreshCw, Sparkles } from 'lucide-react' import type { DiscoverItem, DiscoverSection } from '../api/discover' import { ContentRow } from './DiscoverContentRow' type SectionLabel = (key: string) => string export function DiscoverHeader({ sections, selected, sectionsReady, loading, onRefresh, onToggleSection, }: { sections: DiscoverSection[] selected: string[] sectionsReady: boolean loading: boolean onRefresh: () => void onToggleSection: (key: string) => void }) { return (

发现

多源推荐:TMDb / 豆瓣 / Bangumi,可按需组合显示

{sections.map((section) => { const active = selected.includes(section.key) return ( ) })}
) } export function DiscoverEmptySelection() { return (
至少选择一个推荐源,小宇宙才会开始转动。
) } export function DiscoverResults({ selected, rows, rowLoading, rowErrors, rowPages, rowCanNext, loading, hasContent, imageVersion, refreshImageVersion, sectionLabel, onPageChange, onSelect, }: { selected: string[] rows: Record rowLoading: Record rowErrors: Record rowPages: Record rowCanNext: Record loading: boolean hasContent: boolean imageVersion: string refreshImageVersion?: string sectionLabel: SectionLabel onPageChange: (key: string, delta: number) => void onSelect: (item: DiscoverItem) => void }) { const hasRowErrors = Object.keys(rowErrors).length > 0 return (
{selected.map((key) => { const items = rows[key] ?? [] if (items.length === 0) { if (rowLoading[key]) { return } return null } return ( onPageChange(key, delta)} onSelect={onSelect} /> ) })} {hasRowErrors && ( )} {!loading && !hasContent && !hasRowErrors && }
) } function DiscoverRowErrors({ rowErrors, sectionLabel, }: { rowErrors: Record sectionLabel: SectionLabel }) { return (

部分推荐源暂不可用,其他已加载内容不受影响。

{Object.entries(rowErrors).map(([key, message]) => (

{sectionLabel(key)}:{message}

))}
) } function DiscoverNoContent() { return (

当前选择的推荐源暂未返回内容,可切换豆瓣 / Bangumi 或检查网络代理。

) } function DiscoverRowSkeleton({ title }: { title: string }) { return (

{title}

{[1, 2, 3, 4, 5, 6, 7, 8].map((item) => (
))}
) }