From aee4b489958c8d7be3e1f873fc532fd48449a1ea Mon Sep 17 00:00:00 2001 From: jinghui <3970260761@qq.com> Date: Tue, 10 Nov 2026 17:46:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AE=A1=E7=90=86=E9=A1=B5=E6=AF=8F?= =?UTF-8?q?=E6=AC=A1=E6=89=93=E5=BC=80=E5=8D=B3=E8=87=AA=E5=8A=A8=E6=B5=8B?= =?UTF-8?q?=E9=80=9F=E6=89=80=E6=9C=89=E8=B5=84=E6=BA=90=E7=AB=99(?= =?UTF-8?q?=E6=B5=8B=E9=80=9F=E6=8F=90=E5=8D=87=E5=88=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=BA=A7)=20(fixed124)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- src/app/admin/page.tsx | 52 ++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index b14e7cc..7ae5e91 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=fixed123 +ENV NEXT_PUBLIC_SITE_VERSION=fixed124 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=fixed123 +ENV NEXT_PUBLIC_SITE_VERSION=fixed124 ENV NEXT_PUBLIC_ENABLE_REGISTER=true # 从构建器中复制 standalone 输出 diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index d724803..b4018c3 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -650,16 +650,17 @@ const UserConfig = ({ config, role, refreshConfig }: UserConfigProps) => { const VideoSourceConfig = ({ config, refreshConfig, + speeds, }: { config: AdminConfig | null; refreshConfig: () => Promise; + speeds: Record; }) => { const [sources, setSources] = useState([]); const [showAddForm, setShowAddForm] = useState(false); const [orderChanged, setOrderChanged] = useState(false); const [batchMode, setBatchMode] = useState(false); const [selectedSources, setSelectedSources] = useState>(new Set()); - const [speeds, setSpeeds] = useState>({}); const [newSource, setNewSource] = useState({ name: '', key: '', @@ -694,29 +695,6 @@ const VideoSourceConfig = ({ } }, [config]); - // 打开页面自动测速各资源站响应时间 - useEffect(() => { - let alive = true; - const run = async () => { - try { - const r = await fetch('/api/filter?action=probe'); - const j = await r.json().catch(() => null); - if (!alive) return; - const map: Record = {}; - (j?.results || []).forEach((x: any) => { - map[x.key] = { ms: x.ms, ok: x.ok }; - }); - setSpeeds(map); - } catch { - /* 忽略测速失败 */ - } - }; - run(); - return () => { - alive = false; - }; - }, []); - // 通用 API 请求 const callSourceApi = async (body: Record) => { try { @@ -1704,6 +1682,7 @@ const SiteConfigComponent = ({ config }: { config: AdminConfig | null }) => { function AdminPageClient() { const router = useRouter(); + const [speeds, setSpeeds] = useState>({}); const [config, setConfig] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -1714,6 +1693,29 @@ function AdminPageClient() { siteConfig: false, }); + // 每次打开管理页自动并发测速所有资源站一次 + useEffect(() => { + let alive = true; + const run = async () => { + try { + const r = await fetch('/api/filter?action=probe'); + const j = await r.json().catch(() => null); + if (!alive) return; + const map: Record = {}; + (j?.results || []).forEach((x: any) => { + map[x.key] = { ms: x.ms, ok: x.ok }; + }); + setSpeeds(map); + } catch { + /* 测速失败不阻塞页面 */ + } + }; + run(); + return () => { + alive = false; + }; + }, []); + // 获取管理员配置 // showLoading 用于控制是否在请求期间显示整体加载骨架。 const fetchConfig = useCallback(async (showLoading = false) => { @@ -1873,7 +1875,7 @@ function AdminPageClient() { isExpanded={expandedTabs.videoSource} onToggle={() => toggleTab('videoSource')} > - +