From 41fe467e63842c7ffb5dee23eae2f9a24c9f10f4 Mon Sep 17 00:00:00 2001 From: jinghui <3970260761@qq.com> Date: Tue, 10 Nov 2026 16:58:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20/filter=20=E8=B5=84=E6=BA=90=E7=AB=99?= =?UTF-8?q?=E6=B5=8B=E9=80=9F(=E5=93=8D=E5=BA=94=E7=A7=92)=20+=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=A4=B1=E6=95=88=E5=BD=97=E6=98=9F=E8=B5=84=E6=BA=90?= =?UTF-8?q?=20(fixed122)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- config.json | 5 ----- src/app/api/filter/route.ts | 24 ++++++++++++++++++++++++ src/app/filter/page.tsx | 33 ++++++++++++++++++++++++++++----- 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2007758..c4e260c 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=fixed121 +ENV NEXT_PUBLIC_SITE_VERSION=fixed122 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=fixed121 +ENV NEXT_PUBLIC_SITE_VERSION=fixed122 ENV NEXT_PUBLIC_ENABLE_REGISTER=true # 从构建器中复制 standalone 输出 diff --git a/config.json b/config.json index 193d1e7..fbdaa42 100644 --- a/config.json +++ b/config.json @@ -6,11 +6,6 @@ "name": "无尽资源", "is_adult": false }, - "hhzy": { - "api": "https://hhzyapi.com/api.php/provide/vod", - "name": "彗星资源", - "is_adult": false - }, "bfzy": { "api": "https://bfzyapi.com/api.php/provide/vod", "name": "暴风资源", diff --git a/src/app/api/filter/route.ts b/src/app/api/filter/route.ts index d987b77..260b664 100644 --- a/src/app/api/filter/route.ts +++ b/src/app/api/filter/route.ts @@ -259,6 +259,30 @@ export async function GET(request: NextRequest) { { headers } ); } + if (action === 'probe') { + const results = await Promise.all( + sites.map(async (st) => { + const base = st.api + (st.api.includes('?') ? '&' : '?'); + const t0 = Date.now(); + let ok = false; + try { + const ctrl = new AbortController(); + const tm = setTimeout(() => ctrl.abort(), 6000); + const r = await fetch(base + 'ac=list', { + headers: { 'User-Agent': UA, Accept: 'application/json' }, + signal: ctrl.signal, + }); + clearTimeout(tm); + if (r.ok) { + const j = await r.json().catch(() => null); + ok = !!(j && (Array.isArray(j.list) || Array.isArray(j.class))); + } + } catch {} + return { key: st.key, name: st.name, ms: Date.now() - t0, ok }; + }) + ); + return NextResponse.json({ results }, { headers }); + } if (source === 'all') { if (action === 'classes') { return NextResponse.json( diff --git a/src/app/filter/page.tsx b/src/app/filter/page.tsx index d5c3e03..8bf9204 100644 --- a/src/app/filter/page.tsx +++ b/src/app/filter/page.tsx @@ -127,6 +127,19 @@ function Pills({ function FilterClient() { const searchParams = useSearchParams(); const [sources, setSources] = useState([]); + const runProbe = async () => { + setProbing(true); + try { + const r = await fetch('/api/filter?action=probe'); + const j = await r.json().catch(() => null); + const map: Record = {}; + (j?.results || []).forEach((x: any) => { map[x.key] = { ms: x.ms, ok: x.ok }; }); + setProbe(map); + } catch { setErr('测速失败'); } + finally { setProbing(false); } + }; + const [probe, setProbe] = useState>({}); + const [probing, setProbing] = useState(false); const [source, setSource] = useState('all'); const [classes, setClasses] = useState([]); const [cat, setCat] = useState(() => searchParams.get('t') || searchParams.get('cat') || ''); @@ -271,12 +284,22 @@ function FilterClient() { className='px-3 py-1.5 text-xs sm:text-sm rounded-full bg-gray-200/60 dark:bg-gray-700/60 text-gray-700 dark:text-gray-300 max-w-full' > - {sources.map((s) => ( - - ))} + {sources + .filter((s) => !probe[s.key] || probe[s.key].ok) + .map((s) => ( + + ))} +