From 9d765b9f496fb6b9998bda0a4eb8a913d7a278c8 Mon Sep 17 00:00:00 2001 From: jinghui <3970260761@qq.com> Date: Tue, 10 Nov 2026 16:12:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E6=B8=AF=E5=89=A7?= =?UTF-8?q?=E5=8C=BA=E5=9D=97=205=E5=88=86=E9=92=9F=E7=BC=93=E5=AD=98+?= =?UTF-8?q?=E8=B6=85=E6=97=B6/=E5=A4=B1=E8=B4=A5=E5=85=9C=E5=BA=95=20(fixe?= =?UTF-8?q?d120)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- src/components/HkDramaRow.tsx | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index f1ef956..19b298d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ RUN find ./src -type f -name "route.ts" -print0 \ ENV DOCKER_ENV=true # 海报走站内 /api/image-proxy(浏览器直连豆瓣图被拦导致全裂) ENV NEXT_PUBLIC_IMAGE_PROXY=/api/image-proxy -ENV NEXT_PUBLIC_SITE_VERSION=fixed119 +ENV NEXT_PUBLIC_SITE_VERSION=fixed120 ENV NEXT_PUBLIC_ENABLE_REGISTER=true # For Docker builds, force dynamic rendering to read runtime environment variables. @@ -56,7 +56,7 @@ ENV HOSTNAME=0.0.0.0 ENV PORT=3000 ENV DOCKER_ENV=true ENV NEXT_PUBLIC_IMAGE_PROXY=/api/image-proxy -ENV NEXT_PUBLIC_SITE_VERSION=fixed119 +ENV NEXT_PUBLIC_SITE_VERSION=fixed120 ENV NEXT_PUBLIC_ENABLE_REGISTER=true # 从构建器中复制 standalone 输出 diff --git a/src/components/HkDramaRow.tsx b/src/components/HkDramaRow.tsx index 1af93ee..19fb41e 100644 --- a/src/components/HkDramaRow.tsx +++ b/src/components/HkDramaRow.tsx @@ -23,7 +23,22 @@ export default function HkDramaRow() { const [loading, setLoading] = useState(true); useEffect(() => { - fetch('/api/tvbox/all?ac=videolist&t=902&pg=1&by=time') + const CACHE_KEY = 'hkDramaRow:v1'; + const TTL = 5 * 60 * 1000; + try { + const raw = sessionStorage.getItem(CACHE_KEY); + if (raw) { + const { ts, data } = JSON.parse(raw); + if (Date.now() - ts < TTL && Array.isArray(data)) { + setItems(data); + setLoading(false); + return; + } + } + } catch {} + const ctrl = new AbortController(); + const timer = setTimeout(() => ctrl.abort(), 12000); + fetch('/api/tvbox/all?ac=videolist&t=902&pg=1&by=time', { signal: ctrl.signal }) .then((r) => r.json()) .then((j) => { const arr = (((j && j.list) as VodItem[]) || []).slice(); @@ -35,10 +50,22 @@ export default function HkDramaRow() { String(a.vod_time || '') ); }); - setItems(arr.slice(0, SHOW_COUNT)); + const out = arr.slice(0, SHOW_COUNT); + setItems(out); + try { sessionStorage.setItem(CACHE_KEY, JSON.stringify({ ts: Date.now(), data: out })); } catch {} }) - .catch(() => {}) - .finally(() => setLoading(false)); + .catch(() => { + // 失败兜底:尝试用过期缓存 + try { + const raw = sessionStorage.getItem(CACHE_KEY); + if (raw) { + const { data } = JSON.parse(raw); + if (Array.isArray(data)) setItems(data); + } + } catch {} + }) + .finally(() => { clearTimeout(timer); setLoading(false); }); + return () => { clearTimeout(timer); ctrl.abort(); }; }, []); // 加载失败且无数据时不占位;加载中显示骨架占位,与其它栏目同时出现