优化列表分页和数据加载
This commit is contained in:
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user