v1.1.0: AI分析历史记录 + 数据源详情页(/analysis/<id>),展示大模型参考的RAG新闻/概况/指标/评级/持仓/提示词

This commit is contained in:
2026-08-19 21:00:20 +08:00
parent b0fece63ff
commit 4a9ea9ddd7
8 changed files with 273 additions and 10 deletions
+28 -1
View File
@@ -232,7 +232,9 @@ async function pollReport() {
clearInterval(timer);
$('#analyzeBtn').disabled = false;
$('#reportBox').innerHTML = `<div class="markdown-body">${mdRender(d.report)}</div>
<div style="color:var(--muted);font-size:12px;margin-top:12px">${d.cached ? '缓存报告 ' + d.created_at + '' : '生成耗时 ' + Math.round((Date.now() - t0) / 1000) + ' 秒'}</div>`;
<div style="color:var(--muted);font-size:12px;margin-top:12px">${d.cached ? '最近一次分析记录,' + d.created_at + '' : '生成耗时 ' + Math.round((Date.now() - t0) / 1000) + ' 秒'}
${d.history_id ? ` · <a href="/analysis/${d.history_id}" target="_blank">查看数据源详情 ↗</a>` : ''}</div>`;
loadHistory();
} else if (d.status === 'error') {
clearInterval(timer);
$('#analyzeBtn').disabled = false;
@@ -246,7 +248,32 @@ async function pollReport() {
}, 4000);
}
/* 历史分析记录 */
async function loadHistory() {
try {
const d = await api(`/api/stock/${CODE}/analyses`);
const items = d.items || [];
if (!items.length) {
$('#historyBox').innerHTML = '<div class="empty">暂无历史分析,点击上方「生成研报」开始</div>';
return;
}
$('#historyBox').innerHTML = `<table>
<tr><th>时间</th><th>关注点</th><th>引用资讯</th><th>报告摘要</th><th>操作</th></tr>
${items.map(h => `<tr>
<td style="color:var(--muted)">${h.created_at}</td>
<td>${escapeHtml(h.focus || '整体投资价值')}</td>
<td class="num">${h.news_count} 条</td>
<td style="max-width:300px;white-space:normal;color:var(--text2)">${escapeHtml(h.excerpt)}…</td>
<td><button class="btn btn-primary" onclick="window.open('/analysis/${h.id}','_blank')">查看详情 ↗</button></td>
</tr>`).join('')}
</table>`;
} catch (e) {
$('#historyBox').innerHTML = '<div class="empty">历史记录加载失败</div>';
}
}
$('#analyzeBtn').onclick = generateReport;
$('#focusInput').addEventListener('keydown', e => { if (e.key === 'Enter') generateReport(); });
load();
loadHistory();