diff --git a/assets/image_20260713145227175.png b/assets/image_20260713145227175.png new file mode 100644 index 0000000..43cc583 Binary files /dev/null and b/assets/image_20260713145227175.png differ diff --git a/templates/index.html b/templates/index.html index 4f2489a..ada66ca 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2218,41 +2218,96 @@ return; } + // 解析日期字符串(支持多种格式) + const parseDate = (dateStr) => { + if (!dateStr) return null; + + // 尝试匹配 "2026-07-12" 格式 + let match = dateStr.match(/(\d{4})-(\d{1,2})-(\d{1,2})/); + if (match) { + return { + year: parseInt(match[1]), + month: parseInt(match[2]), + day: parseInt(match[3]) + }; + } + + // 尝试匹配 "Sun, 12 Jul 2026 00:00:00 GMT" 格式 + match = dateStr.match(/(\d{1,2})\s+(\w+)\s+(\d{4})/); + if (match) { + const months = { + 'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, + 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12 + }; + return { + year: parseInt(match[3]), + month: months[match[2]] || 1, + day: parseInt(match[1]) + }; + } + + return null; + }; + + // 解析时间字符串(支持多种格式) + const parseTime = (timeStr) => { + if (!timeStr) return null; + + // 尝试匹配 "2026-07-12 08:00:00" 格式 + let match = timeStr.match(/(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})/); + if (match) { + return { + year: match[1], + month: match[2].padStart(2, '0'), + day: match[3].padStart(2, '0'), + hour: match[4].padStart(2, '0'), + minute: match[5].padStart(2, '0'), + second: match[6].padStart(2, '0') + }; + } + + // 尝试匹配 "Sun, 12 Jul 2026 08:00:00 GMT" 格式 + match = timeStr.match(/(\d{1,2})\s+(\w+)\s+(\d{4})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})/); + if (match) { + const months = { + 'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', + 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12' + }; + return { + year: match[3], + month: months[match[2]] || '01', + day: match[1].padStart(2, '0'), + hour: match[4].padStart(2, '0'), + minute: match[5].padStart(2, '0'), + second: match[6].padStart(2, '0') + }; + } + + return null; + }; + tbody.innerHTML = list.map(item => { const statusText = item.status === 1 ? '成功' : '失败'; const statusClass = item.status === 1 ? 'status-success' : 'status-failed'; - // 格式化报表日期为中文(直接解析字符串格式 '2026-07-12') + // 格式化报表日期为中文 let reportDate = '-'; - if (item.report_date) { - const match = item.report_date.match(/(\d{4})-(\d{1,2})-(\d{1,2})/); - if (match) { - const year = parseInt(match[1]); - const month = parseInt(match[2]); - const day = parseInt(match[3]); - reportDate = `${year}年${month}月${day}日`; - } else { - reportDate = item.report_date; - } + const dateObj = parseDate(item.report_date); + if (dateObj) { + reportDate = `${dateObj.year}年${dateObj.month}月${dateObj.day}日`; + } else if (item.report_date) { + reportDate = item.report_date; } - // 格式化时间范围(直接解析字符串格式 '2026-07-12 08:00:00') + // 格式化时间范围 let timeRange = '-'; - if (item.start_time && item.end_time) { - const formatTimeStr = (timeStr) => { - const match = timeStr.match(/(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})/); - if (match) { - const year = match[1]; - const month = match[2].padStart(2, '0'); - const day = match[3].padStart(2, '0'); - const hour = match[4].padStart(2, '0'); - const minute = match[5].padStart(2, '0'); - const second = match[6].padStart(2, '0'); - return `${year}-${month}-${day} ${hour}:${minute}:${second}`; - } - return timeStr; - }; - timeRange = `${formatTimeStr(item.start_time)} 至 ${formatTimeStr(item.end_time)}`; + const startObj = parseTime(item.start_time); + const endObj = parseTime(item.end_time); + if (startObj && endObj) { + const formatTimeObj = (obj) => `${obj.year}-${obj.month}-${obj.day} ${obj.hour}:${obj.minute}:${obj.second}`; + timeRange = `${formatTimeObj(startObj)} 至 ${formatTimeObj(endObj)}`; + } else if (item.start_time && item.end_time) { + timeRange = `${item.start_time} 至 ${item.end_time}`; } const configName = item.config_name || '-';