feat: 管理页视频源状态列自动显示响应耗时 (fixed123)
Docker Build & Test / build (push) Canceled after 0s
Docker Build & Test / test (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/amd64) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm/v7) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm64) (push) Canceled after 0s
Build & Push Docker image / merge-images (push) Canceled after 0s

This commit is contained in:
jinghui committed 2026-11-10 17:15:48 +08:00
1 parent 41fe467e63
commit dc7787a5ab
2 files changed
+41 -2

No files matched your search

+2 -2
View File
@@ -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=fixed122
ENV NEXT_PUBLIC_SITE_VERSION=fixed123
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=fixed122
ENV NEXT_PUBLIC_SITE_VERSION=fixed123
ENV NEXT_PUBLIC_ENABLE_REGISTER=true
# 从构建器中复制 standalone 输出
+39
View File
@@ -659,6 +659,7 @@ const VideoSourceConfig = ({
const [orderChanged, setOrderChanged] = useState(false);
const [batchMode, setBatchMode] = useState(false);
const [selectedSources, setSelectedSources] = useState<Set<string>>(new Set());
const [speeds, setSpeeds] = useState<Record<string, { ms: number; ok: boolean }>>({});
const [newSource, setNewSource] = useState<DataSource>({
name: '',
key: '',
@@ -693,6 +694,29 @@ 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<string, { ms: number; ok: boolean }> = {};
(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<string, any>) => {
try {
@@ -1120,6 +1144,21 @@ const VideoSourceConfig = ({
>
{!source.disabled ? '启用中' : '已禁用'}
</span>
{!source.disabled && (
<div className='mt-1 text-xs'>
{speeds[source.key] ? (
speeds[source.key].ok ? (
<span className='text-green-600 dark:text-green-400'>
{(speeds[source.key].ms / 1000).toFixed(2)}s
</span>
) : (
<span className='text-red-600 dark:text-red-400'>超时</span>
)
) : (
<span className='text-gray-400 dark:text-gray-500'>测速中…</span>
)}
</div>
)}
</td>
<td className='px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2'>
<button