From 464b0be7040b77dcbbaf0bc0be362f5fdc8bee77 Mon Sep 17 00:00:00 2001 From: scyang <291024738@qq.com> Date: Fri, 13 Mar 2026 12:49:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/index.css | 6 ++++++ src/web/pages/ProxyLogs.tsx | 38 ++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/web/index.css b/src/web/index.css index 18f51ee..3151f7e 100644 --- a/src/web/index.css +++ b/src/web/index.css @@ -877,6 +877,12 @@ body { background: color-mix(in srgb, var(--color-primary) 22%, var(--color-bg-card)); } +.btn-ghost-active { + background: color-mix(in srgb, var(--color-primary) 22%, var(--color-bg-card)); + border-color: var(--color-primary) !important; + color: var(--color-primary); +} + .btn-link { background: transparent; border: none; diff --git a/src/web/pages/ProxyLogs.tsx b/src/web/pages/ProxyLogs.tsx index e2c57d8..8fc6bb4 100644 --- a/src/web/pages/ProxyLogs.tsx +++ b/src/web/pages/ProxyLogs.tsx @@ -219,6 +219,7 @@ export default function ProxyLogs() { const [detailById, setDetailById] = useState>({}); const [showFilters, setShowFilters] = useState(false); const [sites, setSites] = useState>([]); + const [autoRefresh, setAutoRefresh] = useState(false); const isMobile = useIsMobile(768); const toast = useToast(); const loadSeq = useRef(0); @@ -320,7 +321,7 @@ export default function ProxyLogs() { return siteOptions.find((option) => option.value === String(siteFilter))?.label || `站点 #${siteFilter}`; }, [siteFilter, siteOptions]); - const load = useCallback(async () => { + const load = useCallback(async (silent = false) => { const seq = ++loadSeq.current; if (hasInvalidTimeRange) { setLogs([]); @@ -329,7 +330,7 @@ export default function ProxyLogs() { if (seq === loadSeq.current) setLoading(false); return; } - setLoading(true); + if (!silent) setLoading(true); try { const params = { limit: pageSize, @@ -347,7 +348,7 @@ export default function ProxyLogs() { setSummary(data.summary || EMPTY_SUMMARY); } catch (e: any) { if (seq !== loadSeq.current) return; - toast.error(e.message || '加载日志失败'); + if (!silent) toast.error(e.message || '加载日志失败'); } finally { if (seq === loadSeq.current) setLoading(false); } @@ -357,6 +358,12 @@ export default function ProxyLogs() { void load(); }, [load]); + useEffect(() => { + if (!autoRefresh) return; + const timer = setInterval(() => { void load(true); }, 2000); + return () => clearInterval(timer); + }, [autoRefresh, load]); + useEffect(() => { if (page <= totalPages) return; setPage(totalPages); @@ -504,12 +511,25 @@ export default function ProxyLogs() { {summary.totalTokensAll.toLocaleString()} tokens - +
+ + +
{isMobile ? (