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')} > - +