chore remove sse debug logging

This commit is contained in:
ShukeBta
2026-06-30 20:24:40 +08:00
parent 941bb273b9
commit 7cf0e468ff
+1 -8
View File
@@ -16,7 +16,7 @@ type SSEEventHandler = (event: SSEEvent) => void
* function MyComponent() { * function MyComponent() {
* const { connect, disconnect } = useSSE((event) => { * const { connect, disconnect } = useSSE((event) => {
* if (event.type === 'scan') { * if (event.type === 'scan') {
* console.log('Scan progress:', event.payload) * updateScanProgress(event.payload)
* } * }
* }) * })
* *
@@ -59,7 +59,6 @@ export function useSSE(
eventSource.onopen = () => { eventSource.onopen = () => {
isConnectedRef.current = true isConnectedRef.current = true
reconnectAttemptsRef.current = 0 reconnectAttemptsRef.current = 0
console.log('SSE connected')
} }
eventSource.onmessage = (event) => { eventSource.onmessage = (event) => {
@@ -79,18 +78,12 @@ export function useSSE(
if (reconnectAttemptsRef.current < maxReconnectAttempts) { if (reconnectAttemptsRef.current < maxReconnectAttempts) {
const delay = Math.min(1000 * Math.pow(2, reconnectAttemptsRef.current), 30000) const delay = Math.min(1000 * Math.pow(2, reconnectAttemptsRef.current), 30000)
reconnectAttemptsRef.current++ reconnectAttemptsRef.current++
console.log(`SSE reconnecting in ${delay}ms (attempt ${reconnectAttemptsRef.current})`)
reconnectTimeoutRef.current = setTimeout(connect, delay) reconnectTimeoutRef.current = setTimeout(connect, delay)
} else { } else {
console.error('SSE connection failed after max attempts') console.error('SSE connection failed after max attempts')
} }
} }
// 自定义事件类型
eventSource.addEventListener('connected', (event) => {
console.log('SSE handshake received:', event)
})
}, [onEvent]) }, [onEvent])
const disconnect = useCallback(() => { const disconnect = useCallback(() => {