删除返回首页

This commit is contained in:
朱潮 2025-11-30 23:17:55 +08:00
parent 2a015e05dc
commit 7670c48574

View File

@ -595,7 +595,14 @@
if (this.results.sessionStatus === 'report_generated') {
// 报告已生成,按钮可点击
this.showReportButton();
reportBtn.textContent = '查看详细报告';
reportBtn.disabled = false;
reportBtn.style.opacity = '1';
reportBtn.style.cursor = 'pointer';
reportBtn.onclick = () => {
// 获取报告ID并跳转到报告页面
this.navigateToReport();
};
} else {
// 报告未生成,显示"报告生成中"且不可点击
reportBtn.textContent = '报告生成中';
@ -606,15 +613,45 @@
}
}
async navigateToReport() {
try {
// 首先尝试从 results 中获取报告ID
if (this.results.reportId) {
window.location.href = `/report.html?id=${this.results.reportId}`;
return;
}
// 如果没有,则通过 API 获取报告列表
const response = await fetch('/api/reports');
const data = await response.json();
const report = data.reports.find(r => r.session_id === this.sessionId);
if (report) {
window.location.href = `/report.html?id=${report.id}`;
} else {
// 如果找不到报告,显示提示信息
alert('报告正在生成中,请稍后再试');
// 刷新页面重新检查状态
setTimeout(() => {
window.location.reload();
}, 1000);
}
} catch (error) {
console.error('获取报告失败:', error);
alert('获取报告失败,请稍后再试');
}
}
showReportButton() {
const reportBtn = document.getElementById('checkReportBtn');
reportBtn.style.display = 'inline-block';
reportBtn.textContent = '查看详细报告';
reportBtn.disabled = false;
reportBtn.style.opacity = '1';
reportBtn.style.cursor = 'pointer';
reportBtn.onclick = () => {
// 跳转到报告页面,使用 session_id 作为参数
window.location.href = `/report.html?session_id=${this.sessionId}`;
// 获取报告ID并跳转到报告页面
this.navigateToReport();
};
}