From a20e6bb0d7421202edd46c29949dd0306e0593de Mon Sep 17 00:00:00 2001 From: xxm Date: Sun, 16 Aug 2026 07:59:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20toggleAvail/batchAvail=E7=A7=BB=E5=88=B0?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E4=BD=9C=E7=94=A8=E5=9F=9F(onclick=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E8=B0=83=E7=94=A8,=E5=8E=9F=E5=B1=80=E9=83=A8?= =?UTF-8?q?=E5=87=BD=E6=95=B0ReferenceError)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/index.html | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/static/index.html b/static/index.html index 34a53f89..3f88f6fb 100644 --- a/static/index.html +++ b/static/index.html @@ -2302,6 +2302,30 @@ function sortStrategies(strategies, key, dir) { return arr; } +// ── 2026-08-16 手动可用性(全局,供 onclick 调用):激活只能是可用的策略 ── +async function toggleAvail(version, checked) { + try { + await fetch('/api/research/availability', { + method: 'POST', headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({version: version, available: checked, note: '手动切换'}) + }); + loadStrategyList(); // 刷新(state 可能变化) + } catch(e) { console.error('toggleAvail failed', e); } +} +async function batchAvail(rg, available) { + const list = (window._strats || []) + .filter(s => s.best_regime === rg && (s.market || 'all') !== 'hk') + .map(s => s.version); + if (!list.length) return; + try { + await fetch('/api/research/availability?batch=1', { + method: 'POST', headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({versions: list, available: available, note: '批量' + (available ? '可用' : '不可用')}) + }); + loadStrategyList(); + } catch(e) { console.error('batchAvail failed', e); } +} + function renderStrategyTable(strategies) { const el = document.getElementById('strategyList'); if (!strategies.length) { el.innerHTML = '
暂无策略版本
'; return; } @@ -2543,30 +2567,6 @@ function renderStrategyTable(strategies) { cell('portfolio_max_dd_pct', ddV, v => v + '%', '') + ''; }; - // 2026-08-16 手动可用性:切换单个策略(激活只能是可用的策略) - async function toggleAvail(version, checked) { - try { - await fetch('/api/research/availability', { - method: 'POST', headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({version: version, available: checked, note: '手动切换'}) - }); - loadStrategyList(); // 刷新(state 可能变化) - } catch(e) { console.error('toggleAvail failed', e); } - } - // 2026-08-16 批量设置可用性(当前温区表全部) - async function batchAvail(rg, available) { - const list = (window._strats || []) - .filter(s => s.best_regime === rg && (s.market || 'all') !== 'hk') - .map(s => s.version); - if (!list.length) return; - try { - await fetch('/api/research/availability?batch=1', { - method: 'POST', headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({versions: list, available: available, note: '批量' + (available ? '可用' : '不可用')}) - }); - loadStrategyList(); - } catch(e) { console.error('batchAvail failed', e); } - } const renderRegimeTable = (strats, rg, isCur, marketLabel, tempHtml) => { // 2026-08-15 方案A:策略只在适应温区(best_regime)表显示一行——所有列都是该策略在适应温区的数据 // 2026-08-16 温区感知排序:尊重 window._sortKey(点列头排序),字段从 regime_winrates[rg] 取