优化列表分页和数据加载

This commit is contained in:
yml2213
2026-07-24 13:25:27 +08:00
parent 6840728da6
commit f91c05c108
17 changed files with 647 additions and 161 deletions
+4 -2
View File
@@ -12,6 +12,8 @@ interface ConnectOptions {
onResult?: () => void;
}
const MAX_LOGS = 1000;
function toWebSocketUrl(pathOrUrl: string): string {
if (pathOrUrl.startsWith('ws://') || pathOrUrl.startsWith('wss://')) {
return pathOrUrl;
@@ -63,9 +65,9 @@ export function useWebSocketLogs() {
callbacksRef.current.onResult?.();
return;
}
setLogs((prev) => [...prev, msg]);
setLogs((prev) => [...prev, msg].slice(-MAX_LOGS));
} catch {
setLogs((prev) => [...prev, { level: 'info', message: String(event.data) }]);
setLogs((prev) => [...prev, { level: 'info', message: String(event.data) }].slice(-MAX_LOGS));
}
};