现在系统日志的发生时间列将以更直观、易识别的格式显示,提升了用户体验。
This commit is contained in:
@@ -3090,6 +3090,16 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// 初始检查hash
|
||||
handleHashChange();
|
||||
|
||||
// 为进程信息显示数量下拉框添加事件监听
|
||||
const processPageSizeSelect = document.getElementById('processPageSize');
|
||||
if (processPageSizeSelect) {
|
||||
processPageSizeSelect.addEventListener('change', () => {
|
||||
loadProcessInfo(1); // 重置为第一页
|
||||
});
|
||||
// 设置初始值
|
||||
processPageSizeSelect.value = processPagination.itemsPerPage;
|
||||
}
|
||||
});
|
||||
|
||||
// 进程信息分页状态
|
||||
@@ -3116,9 +3126,21 @@ let logPagination = {
|
||||
async function loadProcessInfo(page = 1) {
|
||||
const processTableBody = document.getElementById('processTableBody');
|
||||
const processPaginationContainer = document.getElementById('processPaginationContainer');
|
||||
const processPageSizeSelect = document.getElementById('processPageSize');
|
||||
|
||||
if (!processTableBody) return;
|
||||
|
||||
// 获取并设置每页显示数量
|
||||
if (processPageSizeSelect) {
|
||||
const selectedPageSize = parseInt(processPageSizeSelect.value, 10);
|
||||
if (selectedPageSize !== processPagination.itemsPerPage) {
|
||||
processPagination.itemsPerPage = selectedPageSize;
|
||||
// 重置为第一页
|
||||
page = 1;
|
||||
processPagination.currentPage = 1;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// 构建查询参数
|
||||
const params = new URLSearchParams();
|
||||
@@ -3476,6 +3498,33 @@ async function loadDiskDetails(page = 1) {
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化时间为易识别的日期样式
|
||||
function formatLogTime(timeString) {
|
||||
if (!timeString) return new Date().toLocaleString('zh-CN');
|
||||
|
||||
try {
|
||||
const date = new Date(timeString);
|
||||
if (isNaN(date.getTime())) {
|
||||
// 如果时间解析失败,返回原始字符串
|
||||
return timeString;
|
||||
}
|
||||
|
||||
// 格式化为:2025-12-04 16:02:28
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error formatting log time:', error);
|
||||
return timeString;
|
||||
}
|
||||
}
|
||||
|
||||
// 加载系统日志
|
||||
async function loadSystemLogs(page = 1) {
|
||||
console.log('loadSystemLogs function called');
|
||||
@@ -3553,7 +3602,7 @@ async function loadSystemLogs(page = 1) {
|
||||
row.innerHTML = `
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${startIndex + index + 1}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900 font-medium">${log.source || 'System'}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.time || new Date().toLocaleString()}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${formatLogTime(log.time)}</td>
|
||||
<td class="px-6 py-4 whitespace-normal text-sm text-gray-500">${log.message || 'No message'}</td>
|
||||
`;
|
||||
logTableBody.appendChild(row);
|
||||
|
||||
Reference in New Issue
Block a user