mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-28 13:27:33 +08:00
mobile ux + logs: hide title on phone and preload last 10 logs
This commit is contained in:
@@ -12,6 +12,19 @@ const Logs: React.FC = () => {
|
||||
const logEndRef = useRef<HTMLDivElement>(null);
|
||||
const abortControllerRef = useRef<AbortController | null>(null);
|
||||
|
||||
const loadRecent = async () => {
|
||||
try {
|
||||
const r = await fetch(`/webui/api/logs/recent${q ? `${q}&limit=10` : '?limit=10'}`);
|
||||
if (!r.ok) return;
|
||||
const j = await r.json();
|
||||
if (Array.isArray(j.logs)) {
|
||||
setLogs(j.logs as LogEntry[]);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('load recent logs failed', e);
|
||||
}
|
||||
};
|
||||
|
||||
const startStreaming = async () => {
|
||||
if (abortControllerRef.current) abortControllerRef.current.abort();
|
||||
abortControllerRef.current = new AbortController();
|
||||
@@ -51,6 +64,7 @@ const Logs: React.FC = () => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadRecent();
|
||||
if (isStreaming) {
|
||||
startStreaming();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user