mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-15 03:57:30 +08:00
mobile ux + logs: hide title on phone and preload last 10 logs
This commit is contained in:
@@ -21,7 +21,7 @@ const Header: React.FC = () => {
|
||||
<div className="w-8 h-8 md:w-9 md:h-9 rounded-xl bg-indigo-500 flex items-center justify-center shadow-lg shadow-indigo-500/20 shrink-0">
|
||||
<Terminal className="w-4 h-4 md:w-5 md:h-5 text-white" />
|
||||
</div>
|
||||
<span className="font-semibold text-lg md:text-xl tracking-tight truncate">ClawGo</span>
|
||||
<span className="hidden md:inline font-semibold text-lg md:text-xl tracking-tight truncate">ClawGo</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 md:gap-6">
|
||||
|
||||
@@ -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