feat: 加载提示更显著(琥珀色粗体+最小显示400ms)+确保切周期时可见

This commit is contained in:
xxm
2026-08-18 08:58:29 +08:00
parent d99c70b858
commit ecc98fa706
+15 -3
View File
@@ -2201,7 +2201,7 @@ function renderResearch() {
'<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="load-hint" class="hidden text-slate-400 text-sm py-2 px-2 animate-pulse"></div>' +
'<div id="load-hint" class="hidden text-amber-300 text-sm font-semibold py-3 px-3 mb-1 rounded border border-amber-500/40 bg-amber-500/10 animate-pulse"></div>' +
'<div id="strategyList"><div class="text-slate-500 text-sm">加载中...</div></div>' +
'<div id="strategyDetail" class="mt-4"></div>' +
'</div>' +
@@ -2262,7 +2262,11 @@ async function loadStrategyList() {
const listEl = document.getElementById('strategyList');
// 2026-08-18 加载中提示(独立提示条,不破坏 strategyList 旧内容/滚动)
const hintEl = document.getElementById('load-hint');
if (hintEl) { hintEl.textContent = '⏳ 加载中...'; hintEl.classList.remove('hidden'); }
if (hintEl) {
hintEl.textContent = '⏳ 加载中...';
hintEl.classList.remove('hidden');
window._hintShownAt = Date.now(); // 记录显示时刻,保证最小可见时长
}
try {
const ptMap = {'1m':'1m','6m':'6m','1y':'1y','2y':'2y','5y':'5y','10y':'10y'};
const pt = ptMap[window._btPeriodVal || document.getElementById('btPeriod')?.value || '2y'] || '2y';
@@ -2298,7 +2302,15 @@ async function loadStrategyList() {
}
}
renderStrategyTable(strats);
if (hintEl) hintEl.classList.add('hidden');
// 2026-08-18 最小显示400ms:即使fetch快也让用户看到加载提示
if (hintEl) {
const waited = Date.now() - (window._hintShownAt || 0);
if (waited < 400) {
setTimeout(() => hintEl.classList.add('hidden'), 400 - waited);
} else {
hintEl.classList.add('hidden');
}
}
} catch(e) {
listEl.innerHTML = '<div class="text-red-400">加载失败: ' + e.message + '</div>';
if (hintEl) { hintEl.textContent = '⚠️ 加载失败'; hintEl.classList.remove('hidden'); }