| 367 | } |
| 368 | |
| 369 | function overrideGenerationRenderers() { |
| 370 | window.renderReports = function renderReportsOverride(reports) { |
| 371 | const docs = reports.created_docs || []; |
| 372 | uiState.recentReportIds = docs.map((doc) => doc.report_id).filter(Boolean); |
| 373 | byId("reportResults").classList.remove("hidden"); |
| 374 | if (!docs.length) { |
| 375 | byId("reportList").className = "empty"; |
| 376 | byId("reportList").textContent = "本次没有生成报告。"; |
| 377 | return; |
| 378 | } |
| 379 | byId("reportList").className = ""; |
| 380 | byId("reportList").innerHTML = docs.map((doc) => { |
| 381 | const reportPath = doc.report_path ? `<p>Markdown:<code>${window.escapeHtml(doc.report_path)}</code></p>` : ""; |
| 382 | const pdfPath = doc.pdf_path ? `<p>PDF:<code>${window.escapeHtml(doc.pdf_path)}</code></p>` : ""; |
| 383 | const url = doc.url ? `<p><a href="${doc.url}" target="_blank" rel="noreferrer">打开飞书文档</a></p>` : ""; |
| 384 | const openAction = doc.report_id ? `<div class="actions"><button type="button" data-open-report="${window.escapeHtml(doc.report_id)}">在报告阅读中打开</button></div>` : ""; |
| 385 | return `<div class="report-item"><h4>${window.escapeHtml(doc.title || doc.paper?.title || "精读报告")}</h4>${reportPath}${pdfPath}${url}${openAction}</div>`; |
| 386 | }).join(""); |
| 387 | }; |
| 388 | |
| 389 | window.renderReportList = function renderReportListOverride(targetId, reports) { |
| 390 | const docs = reports.created_docs || []; |
| 391 | uiState.recentReportIds = docs.map((doc) => doc.report_id).filter(Boolean); |
| 392 | const target = byId(targetId); |
| 393 | if (!docs.length) { |
| 394 | target.className = "empty"; |
| 395 | target.textContent = "本次没有生成报告。"; |
| 396 | return; |
| 397 | } |
| 398 | target.className = ""; |
| 399 | target.innerHTML = docs.map((doc) => { |
| 400 | const reportPath = doc.report_path ? `<p>Markdown:<code>${window.escapeHtml(doc.report_path)}</code></p>` : ""; |
| 401 | const pdfPath = doc.pdf_path ? `<p>PDF:<code>${window.escapeHtml(doc.pdf_path)}</code></p>` : ""; |
| 402 | const url = doc.url ? `<p><a href="${doc.url}" target="_blank" rel="noreferrer">打开飞书文档</a></p>` : ""; |
| 403 | const openAction = doc.report_id ? `<div class="actions"><button type="button" data-open-report="${window.escapeHtml(doc.report_id)}">在报告阅读中打开</button></div>` : ""; |
| 404 | return `<div class="report-item"><h4>${window.escapeHtml(doc.title || doc.paper?.title || "精读报告")}</h4>${reportPath}${pdfPath}${url}${openAction}</div>`; |
| 405 | }).join(""); |
| 406 | }; |
| 407 | } |
| 408 | |
| 409 | function bindReportsEvents() { |
| 410 | byId("userSelect")?.addEventListener("change", () => { |