新增持仓分析 prompt 生成功能
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,7 @@
|
||||
<div class="section-title" style="margin-top:28px;display:flex;align-items:center;gap:12px;">
|
||||
<span>持仓排名 · 前20</span>
|
||||
<input type="date" id="pos-date-select" value="{{ selected_pos_date }}" min="{{ pos_dates[-1] }}" max="{{ pos_dates[0] }}" onchange="changePosDate(this.value)" style="font-size:0.82rem;padding:4px 10px;border:1px solid var(--border);border-radius:5px;background:var(--surface);color:var(--fg);cursor:pointer;">
|
||||
<button onclick="openAnalysisDrawer()" style="margin-left:auto;padding:6px 16px;border:1px solid var(--accent);border-radius:5px;background:var(--accent-light);color:var(--accent);cursor:pointer;font-size:0.82rem;font-weight:600;white-space:nowrap;">AI 分析</button>
|
||||
</div>
|
||||
|
||||
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:16px;margin-bottom:24px;">
|
||||
@@ -108,6 +109,18 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div id="analysisOverlay" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:99;" onclick="closeAnalysisDrawer()"></div>
|
||||
<div id="analysisDrawer" style="display:none;position:fixed;top:0;right:0;width:700px;max-width:95vw;height:100%;background:var(--surface);border-left:1px solid var(--border);z-index:100;box-shadow:-4px 0 24px rgba(0,0,0,.12);transform:translateX(100%);transition:transform .25s ease;display:flex;flex-direction:column;">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--border);">
|
||||
<h3 style="margin:0;font-size:1rem;">持仓分析 {{ contract }}</h3>
|
||||
<div style="display:flex;gap:8px;">
|
||||
<button onclick="copyPrompt()" style="padding:4px 12px;border:1px solid var(--border);border-radius:4px;background:var(--surface);color:var(--fg);cursor:pointer;font-size:0.78rem;">复制</button>
|
||||
<button onclick="closeAnalysisDrawer()" style="background:none;border:none;font-size:1.3rem;cursor:pointer;color:var(--sub);line-height:1;">×</button>
|
||||
</div>
|
||||
</div>
|
||||
<pre id="analysisContent" style="flex:1;margin:0;padding:16px 20px;overflow-y:auto;font-size:0.78rem;line-height:1.6;white-space:pre-wrap;word-break:break-all;color:var(--fg);background:var(--bg);">加载中...</pre>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function changePosDate(d) {
|
||||
var url = new URL(window.location);
|
||||
@@ -163,5 +176,55 @@ function showDrawer(cell, product, calcRows, isNext) {
|
||||
activeRow = row;
|
||||
}
|
||||
}
|
||||
|
||||
var promptText = '';
|
||||
function openAnalysisDrawer() {
|
||||
var overlay = document.getElementById('analysisOverlay');
|
||||
var drawer = document.getElementById('analysisDrawer');
|
||||
drawer.style.display = 'flex';
|
||||
overlay.style.display = 'block';
|
||||
requestAnimationFrame(function() {
|
||||
drawer.style.transform = 'translateX(0)';
|
||||
});
|
||||
var content = document.getElementById('analysisContent');
|
||||
if (promptText) {
|
||||
content.textContent = promptText;
|
||||
return;
|
||||
}
|
||||
content.textContent = '加载中...';
|
||||
fetch('/contracts/{{ contract }}/analysis-prompt')
|
||||
.then(function(r) { return r.text(); })
|
||||
.then(function(t) {
|
||||
promptText = t;
|
||||
content.textContent = t;
|
||||
})
|
||||
.catch(function() { content.textContent = '加载失败'; });
|
||||
}
|
||||
function closeAnalysisDrawer() {
|
||||
document.getElementById('analysisOverlay').style.display = 'none';
|
||||
document.getElementById('analysisDrawer').style.transform = 'translateX(100%)';
|
||||
}
|
||||
function copyPrompt() {
|
||||
navigator.clipboard.writeText(promptText).then(function() {
|
||||
showToast('已复制到剪贴板');
|
||||
});
|
||||
}
|
||||
function showToast(msg) {
|
||||
var t = document.getElementById('toast');
|
||||
if (!t) {
|
||||
t = document.createElement('div');
|
||||
t.id = 'toast';
|
||||
t.style.cssText = 'position:fixed;top:20px;left:50%;transform:translateX(-50%);background:#1e293b;color:#fff;padding:10px 24px;border-radius:8px;font-size:0.88rem;z-index:999;transition:opacity .3s,transform .3s;opacity:0;pointer-events:none;';
|
||||
document.body.appendChild(t);
|
||||
}
|
||||
t.textContent = msg;
|
||||
t.style.opacity = '1';
|
||||
t.style.transform = 'translateX(-50%) translateY(0)';
|
||||
clearTimeout(t._tid);
|
||||
t._tid = setTimeout(function() {
|
||||
t.style.opacity = '0';
|
||||
t.style.transform = 'translateX(-50%) translateY(-10px)';
|
||||
}, 1500);
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user