|
|
@ -538,6 +538,7 @@ |
|
|
|
<button class="btn-small" id="add-test-data-btn" title="添加测试数据">测试</button> |
|
|
|
<button class="btn-small" id="reconnect-btn" title="重新连接">重连</button> |
|
|
|
<button class="btn-small" id="debug-btn" title="调试信息">调试</button> |
|
|
|
<button class="btn-small" id="test-connection-btn" title="测试连接">测试连接</button> |
|
|
|
<div class="column-settings"> |
|
|
|
<button class="btn-small" id="column-settings-btn" title="列设置">列设置</button> |
|
|
|
<div class="column-settings-dropdown" id="column-settings-dropdown"> |
|
|
@ -622,6 +623,7 @@ |
|
|
|
const addTestDataBtn = document.getElementById('add-test-data-btn'); |
|
|
|
const reconnectBtn = document.getElementById('reconnect-btn'); |
|
|
|
const debugBtn = document.getElementById('debug-btn'); |
|
|
|
const testConnectionBtn = document.getElementById('test-connection-btn'); |
|
|
|
const logListPanel = document.querySelector('.log-list-panel'); |
|
|
|
const resizer = document.getElementById('drag-resizer'); |
|
|
|
const layerFilterOptions = document.getElementById('layer-filter-options'); |
|
|
@ -1072,6 +1074,12 @@ |
|
|
|
|
|
|
|
eventSource = new EventSource('/api/websocket/logs/stream'); |
|
|
|
|
|
|
|
// 添加连接打开事件监听 |
|
|
|
eventSource.onopen = function(event) { |
|
|
|
console.log('EventSource onopen 事件:', event); |
|
|
|
updateConnectionStatus('connected', '已连接'); |
|
|
|
}; |
|
|
|
|
|
|
|
eventSource.addEventListener('connected', function(event) { |
|
|
|
console.log("SSE连接已建立", event); |
|
|
|
updateConnectionStatus('connected', '已连接'); |
|
|
@ -1081,6 +1089,7 @@ |
|
|
|
|
|
|
|
eventSource.addEventListener('history', function(event) { |
|
|
|
console.log("接收到历史日志事件", event); |
|
|
|
console.log("历史日志原始数据:", event.data); |
|
|
|
try { |
|
|
|
const data = JSON.parse(event.data); |
|
|
|
console.log("历史日志数据:", data); |
|
|
@ -1093,12 +1102,14 @@ |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error("解析历史日志数据失败:", error); |
|
|
|
console.error("原始数据:", event.data); |
|
|
|
showError("解析历史日志数据失败: " + error.message); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
eventSource.addEventListener('new_logs', function(event) { |
|
|
|
console.log("接收到新日志事件", event); |
|
|
|
console.log("新日志原始数据:", event.data); |
|
|
|
try { |
|
|
|
const data = JSON.parse(event.data); |
|
|
|
console.log("新日志数据:", data); |
|
|
@ -1110,6 +1121,7 @@ |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error("解析新日志数据失败:", error); |
|
|
|
console.error("原始数据:", event.data); |
|
|
|
showError("解析新日志数据失败: " + error.message); |
|
|
|
} |
|
|
|
}); |
|
|
@ -1158,6 +1170,7 @@ |
|
|
|
|
|
|
|
eventSource.onerror = function (err) { |
|
|
|
console.error("SSE 连接错误:", err); |
|
|
|
console.error("EventSource readyState:", eventSource.readyState); |
|
|
|
updateConnectionStatus('error', '连接失败'); |
|
|
|
|
|
|
|
// 自动重连 |
|
|
@ -1272,10 +1285,12 @@ |
|
|
|
sortField: sortField, |
|
|
|
sortDirection: sortDirection, |
|
|
|
columnVisibility: columnVisibility, |
|
|
|
clusterizeRows: clusterize.rows.length |
|
|
|
clusterizeRows: clusterize.rows.length, |
|
|
|
url: window.location.href, |
|
|
|
userAgent: navigator.userAgent |
|
|
|
}; |
|
|
|
|
|
|
|
console.log('调试信息:', debugInfo); |
|
|
|
console.log('前端调试信息:', debugInfo); |
|
|
|
|
|
|
|
// 检查服务器端日志缓存状态 |
|
|
|
fetch('/api/websocket/logs/debug') |
|
|
@ -1288,6 +1303,30 @@ |
|
|
|
console.error('获取服务器调试信息失败:', error); |
|
|
|
showError('获取服务器调试信息失败: ' + error.message); |
|
|
|
}); |
|
|
|
|
|
|
|
// 检查SSE连接状态 |
|
|
|
fetch('/api/websocket/logs/connection-status') |
|
|
|
.then(response => response.json()) |
|
|
|
.then(data => { |
|
|
|
console.log('SSE连接状态:', data); |
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
console.error('获取SSE连接状态失败:', error); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
testConnectionBtn.addEventListener('click', function() { |
|
|
|
// 测试连接 |
|
|
|
fetch('/api/websocket/logs/test-connection') |
|
|
|
.then(response => response.json()) |
|
|
|
.then(data => { |
|
|
|
if (data.message) { |
|
|
|
showInfo(data.message); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
showError('测试连接失败: ' + error.message); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// --- Resizer Logic --- |
|
|
|