Showing
1 changed file
with
46 additions
and
5 deletions
| @@ -3535,6 +3535,9 @@ | @@ -3535,6 +3535,9 @@ | ||
| 3535 | // 日志数据已通过Socket.IO/SSE实时同步,无需重新加载 | 3535 | // 日志数据已通过Socket.IO/SSE实时同步,无需重新加载 |
| 3536 | // 仅保留特殊页面的初始化逻辑 | 3536 | // 仅保留特殊页面的初始化逻辑 |
| 3537 | if (app === 'report') { | 3537 | if (app === 'report') { |
| 3538 | + // 【修复】切换到Report Engine时启动日志刷新 | ||
| 3539 | + startReportLogRefresh(); | ||
| 3540 | + | ||
| 3538 | // 只在报告界面未初始化时才重新加载 | 3541 | // 只在报告界面未初始化时才重新加载 |
| 3539 | const reportContent = document.getElementById('reportContent'); | 3542 | const reportContent = document.getElementById('reportContent'); |
| 3540 | if (!reportContent || reportContent.children.length === 0) { | 3543 | if (!reportContent || reportContent.children.length === 0) { |
| @@ -3544,6 +3547,9 @@ | @@ -3544,6 +3547,9 @@ | ||
| 3544 | setTimeout(() => { | 3547 | setTimeout(() => { |
| 3545 | checkReportLockStatus(); | 3548 | checkReportLockStatus(); |
| 3546 | }, 500); | 3549 | }, 500); |
| 3550 | + } else { | ||
| 3551 | + // 【修复】切换离开Report Engine时停止日志刷新,节省资源 | ||
| 3552 | + stopReportLogRefresh(); | ||
| 3547 | } | 3553 | } |
| 3548 | } | 3554 | } |
| 3549 | 3555 | ||
| @@ -4695,9 +4701,14 @@ | @@ -4695,9 +4701,14 @@ | ||
| 4695 | appStatus.report = 'stopped'; | 4701 | appStatus.report = 'stopped'; |
| 4696 | } | 4702 | } |
| 4697 | } | 4703 | } |
| 4698 | - | 4704 | + |
| 4699 | // 渲染报告界面 | 4705 | // 渲染报告界面 |
| 4700 | renderReportInterface(data); | 4706 | renderReportInterface(data); |
| 4707 | + | ||
| 4708 | + // 【修复】加载Report界面时启动日志刷新 | ||
| 4709 | + if (currentApp === 'report') { | ||
| 4710 | + startReportLogRefresh(); | ||
| 4711 | + } | ||
| 4701 | } else { | 4712 | } else { |
| 4702 | reportContent.innerHTML = ` | 4713 | reportContent.innerHTML = ` |
| 4703 | <div class="report-status error"> | 4714 | <div class="report-status error"> |
| @@ -5101,7 +5112,10 @@ | @@ -5101,7 +5112,10 @@ | ||
| 5101 | if (data.success) { | 5112 | if (data.success) { |
| 5102 | reportTaskId = data.task_id; | 5113 | reportTaskId = data.task_id; |
| 5103 | showMessage('报告生成已启动', 'success'); | 5114 | showMessage('报告生成已启动', 'success'); |
| 5104 | - | 5115 | + |
| 5116 | + // 【修复】立即启动日志实时刷新,确保日志实时显示 | ||
| 5117 | + startReportLogRefresh(); | ||
| 5118 | + | ||
| 5105 | // 更新任务状态显示 | 5119 | // 更新任务状态显示 |
| 5106 | updateTaskProgressStatus({ | 5120 | updateTaskProgressStatus({ |
| 5107 | task_id: data.task_id, | 5121 | task_id: data.task_id, |
| @@ -5111,12 +5125,12 @@ | @@ -5111,12 +5125,12 @@ | ||
| 5111 | created_at: new Date().toISOString(), | 5125 | created_at: new Date().toISOString(), |
| 5112 | updated_at: new Date().toISOString() | 5126 | updated_at: new Date().toISOString() |
| 5113 | }); | 5127 | }); |
| 5114 | - | 5128 | + |
| 5115 | // 立即刷新一次日志以确保同步 | 5129 | // 立即刷新一次日志以确保同步 |
| 5116 | setTimeout(() => { | 5130 | setTimeout(() => { |
| 5117 | refreshReportLog(); | 5131 | refreshReportLog(); |
| 5118 | }, 500); | 5132 | }, 500); |
| 5119 | - | 5133 | + |
| 5120 | appendReportStreamLine('任务创建成功,正在建立流式连接...', 'info', { force: true }); | 5134 | appendReportStreamLine('任务创建成功,正在建立流式连接...', 'info', { force: true }); |
| 5121 | if (window.EventSource) { | 5135 | if (window.EventSource) { |
| 5122 | openReportStream(reportTaskId); | 5136 | openReportStream(reportTaskId); |
| @@ -5147,12 +5161,39 @@ | @@ -5147,12 +5161,39 @@ | ||
| 5147 | }); | 5161 | }); |
| 5148 | } | 5162 | } |
| 5149 | 5163 | ||
| 5164 | + // 【修复】启动Report Engine日志实时刷新 | ||
| 5165 | + function startReportLogRefresh() { | ||
| 5166 | + // 清除旧的定时器 | ||
| 5167 | + if (reportLogRefreshInterval) { | ||
| 5168 | + clearInterval(reportLogRefreshInterval); | ||
| 5169 | + reportLogRefreshInterval = null; | ||
| 5170 | + } | ||
| 5171 | + | ||
| 5172 | + // 启动新的日志刷新定时器(1秒刷新一次,保证实时性) | ||
| 5173 | + reportLogRefreshInterval = setInterval(() => { | ||
| 5174 | + if (currentApp === 'report') { | ||
| 5175 | + refreshReportLog(); | ||
| 5176 | + } | ||
| 5177 | + }, 1000); // 1秒刷新,确保日志实时显示 | ||
| 5178 | + | ||
| 5179 | + console.log('[Report日志] 启动实时日志刷新,频率: 1秒'); | ||
| 5180 | + } | ||
| 5181 | + | ||
| 5182 | + // 【修复】停止Report Engine日志刷新 | ||
| 5183 | + function stopReportLogRefresh() { | ||
| 5184 | + if (reportLogRefreshInterval) { | ||
| 5185 | + clearInterval(reportLogRefreshInterval); | ||
| 5186 | + reportLogRefreshInterval = null; | ||
| 5187 | + console.log('[Report日志] 停止日志刷新'); | ||
| 5188 | + } | ||
| 5189 | + } | ||
| 5190 | + | ||
| 5150 | // 开始进度轮询 | 5191 | // 开始进度轮询 |
| 5151 | function startProgressPolling(taskId) { | 5192 | function startProgressPolling(taskId) { |
| 5152 | if (reportPollingInterval) { | 5193 | if (reportPollingInterval) { |
| 5153 | clearInterval(reportPollingInterval); | 5194 | clearInterval(reportPollingInterval); |
| 5154 | } | 5195 | } |
| 5155 | - | 5196 | + |
| 5156 | reportPollingInterval = setInterval(() => { | 5197 | reportPollingInterval = setInterval(() => { |
| 5157 | checkTaskProgress(taskId); | 5198 | checkTaskProgress(taskId); |
| 5158 | }, 2000); | 5199 | }, 2000); |
-
Please register or login to post a comment