diff --git a/LTEMvcApp/Views/Home/ClientMessages.cshtml b/LTEMvcApp/Views/Home/ClientMessages.cshtml index aff8605..cc73d87 100644 --- a/LTEMvcApp/Views/Home/ClientMessages.cshtml +++ b/LTEMvcApp/Views/Home/ClientMessages.cshtml @@ -173,9 +173,6 @@ - - 配置 -
@@ -183,10 +180,18 @@
消息日志文件管理
-
- 0 个文件 | - 0 KB | - - +
+ +
+ 0 个文件 | + 0 KB | + - + + + +
@@ -281,6 +286,7 @@ let receivedMessagesData = []; let sentClusterize, receivedClusterize; let currentLogFileName = ''; + let logFilesAutoRefreshInterval = null; $(document).ready(function() { // 初始化虚拟滚动列表 @@ -310,17 +316,52 @@ } else { $('#connection-status').removeClass('badge-secondary').addClass('badge-danger').text('未指定客户端地址,无法连接消息流'); } + // 加载日志文件列表 loadLogFiles(); + + // 启动自动刷新(每10秒检查一次) + startLogFilesAutoRefresh(); + // 绑定事件 $('#refreshLogFiles').click(loadLogFiles); + $('#refreshLogFilesBtn').click(function() { + $(this).find('i').addClass('fa-spin'); + loadLogFiles(); + setTimeout(() => { + $(this).find('i').removeClass('fa-spin'); + }, 1000); + }); $('#logContentLines').change(function() { if (currentLogFileName) { loadLogContent(currentLogFileName, $(this).val()); } }); + + // 页面卸载时清理定时器 + $(window).on('beforeunload', function() { + stopLogFilesAutoRefresh(); + }); }); + // 启动日志文件自动刷新 + function startLogFilesAutoRefresh() { + if (logFilesAutoRefreshInterval) { + clearInterval(logFilesAutoRefreshInterval); + } + logFilesAutoRefreshInterval = setInterval(function() { + loadLogFiles(); + }, 10000); // 每10秒刷新一次 + } + + // 停止日志文件自动刷新 + function stopLogFilesAutoRefresh() { + if (logFilesAutoRefreshInterval) { + clearInterval(logFilesAutoRefreshInterval); + logFilesAutoRefreshInterval = null; + } + } + // 加载日志文件列表 function loadLogFiles() { $('#logFilesContainer').html('
正在加载日志文件列表...
'); @@ -340,14 +381,28 @@ $('#totalSize').text(totalSizeKB); $('#lastUpdate').text(new Date().toLocaleTimeString()); } else { - $('#logFilesContainer').html('
暂无日志文件
'); + $('#logFilesContainer').html(` +
+ +
暂无日志文件
+ + 日志文件将在客户端发送或接收消息时自动创建 + +
+ `); $('#totalFiles').text('0/0'); $('#totalSize').text('0'); $('#lastUpdate').text(new Date().toLocaleTimeString()); } }) .fail(function(xhr) { - $('#logFilesContainer').html('
加载日志文件列表失败: ' + (xhr.responseJSON?.message || xhr.statusText) + '
'); + $('#logFilesContainer').html(` +
+ +
加载日志文件列表失败
+ ${xhr.responseJSON?.message || xhr.statusText} +
+ `); }); } diff --git a/LTEMvcApp/Views/Shared/_Layout.cshtml b/LTEMvcApp/Views/Shared/_Layout.cshtml index acc45b3..22ccf58 100644 --- a/LTEMvcApp/Views/Shared/_Layout.cshtml +++ b/LTEMvcApp/Views/Shared/_Layout.cshtml @@ -230,9 +230,9 @@ - + *@