'use client'; import Link from 'next/link'; import { useEffect, useState } from 'react'; type VodItem = { vod_id?: string | number; vod_name?: string; vod_pic?: string; vod_remarks?: string; vod_year?: string; vod_time?: string; }; const SHOW_COUNT = 10; export default function HkDramaRow() { const [items, setItems] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetch('/api/tvbox/all?ac=videolist&t=902&pg=1&by=time') .then((r) => r.json()) .then((j) => { const arr = (((j && j.list) as VodItem[]) || []).slice(); arr.sort((a, b) => { const ya = parseInt(a.vod_year || '', 10) || 0; const yb = parseInt(b.vod_year || '', 10) || 0; if (yb !== ya) return yb - ya; return String(b.vod_time || '').localeCompare( String(a.vod_time || '') ); }); setItems(arr.slice(0, SHOW_COUNT)); }) .catch(() => {}) .finally(() => setLoading(false)); }, []); // 加载失败且无数据时不占位;加载中显示骨架占位,与其它栏目同时出现 if (!loading && !items.length) return null; return (

最新港剧

查看更多
{loading ? // 加载中显示10个占位,与热门电影/剧集同时出现,避免后半拍跳动 Array.from({ length: SHOW_COUNT }).map((_, index) => (
)) : items.map((v) => { const key = String(v.vod_id || ''); const sep = key.indexOf(':'); const ks = sep > 0 ? key.slice(0, sep) : ''; const kid = sep > 0 ? key.slice(sep + 1) : key; const pic = v.vod_pic ? '/api/image-proxy?url=' + encodeURIComponent(v.vod_pic) : ''; return (
{pic ? ( {v.vod_name ) : null} {v.vod_remarks ? ( {v.vod_remarks} ) : null}
{v.vod_name}
); })}
); }