fix: 期间选择持久化——自动刷新不再重置为近2年

This commit is contained in:
hmo
2026-07-30 17:57:34 +08:00
parent e8d0027cd2
commit ff55a46b9d
+13 -3
View File
@@ -1931,14 +1931,24 @@ function renderResearch() {
if (!el) return;
el.innerHTML = '<div class="flex gap-2 items-center mb-3 flex-wrap">' +
'<h2 class="text-lg font-bold">📋 策略研究 — 版本迭代对比</h2>' +
'<select id="btPeriod" onchange="loadStrategyList()" class="bg-slate-800 text-sm rounded-lg px-2 py-1 border border-slate-700">' +
'<select id="btPeriod" onchange="saveBtPeriod()" class="bg-slate-800 text-sm rounded-lg px-2 py-1 border border-slate-700">' +
'<option value="1m">近 1 个月</option><option value="6m">近 6 个月</option>' +
'<option value="1y">近 1 年</option><option value="2y" selected>近 2 年</option><option value="5y">近 5 年</option></select>' +
'<option value="1y">近 1 年</option><option value="2y">近 2 年</option><option value="5y">近 5 年</option></select>' +
'<select id="btMarket" class="bg-slate-800 text-sm rounded-lg px-2 py-1 border border-slate-700" onchange="loadStrategyList()">' +
'<option value="all">全部市场</option><option value="a">A股</option><option value="hk">港股</option></select>' +
'<span class="text-xs text-slate-500">每版策略基于上一版归因分析迭代 · 点击行展开明细</span></div>' +
'<div id="strategyList"><div class="text-slate-500 text-sm">加载中...</div></div>' +
'<div id="strategyDetail" class="mt-4"></div>';
// 恢复用户上次选择的周期(防自动刷新重置,2026-07-30老爸抓包)
const savedPt = window._btPeriodVal || '2y';
const ptSel = document.getElementById('btPeriod');
if (ptSel) ptSel.value = savedPt;
loadStrategyList();
}
function saveBtPeriod() {
const sel = document.getElementById('btPeriod');
if (sel) window._btPeriodVal = sel.value;
loadStrategyList();
}
@@ -1946,7 +1956,7 @@ async function loadStrategyList() {
const listEl = document.getElementById('strategyList');
try {
const ptMap = {'1m':'1m','6m':'6m','1y':'1y','2y':'2y','5y':'5y'};
const pt = ptMap[document.getElementById('btPeriod')?.value || '2y'] || '2y';
const pt = ptMap[window._btPeriodVal || document.getElementById('btPeriod')?.value || '2y'] || '2y';
const resp = await fetch('/api/research/strategies?period_tag=' + pt);
const data = await resp.json();
if (data.error) { listEl.innerHTML = '<div class="text-red-400">' + data.error + '</div>'; return; }