fix: toggleAvail/batchAvail移到全局作用域(onclick全局调用,原局部函数ReferenceError)
This commit is contained in:
+24
-24
@@ -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 = '<div class="text-slate-500">暂无策略版本</div>'; return; }
|
||||
@@ -2543,30 +2567,6 @@ function renderStrategyTable(strategies) {
|
||||
cell('portfolio_max_dd_pct', ddV, v => v + '%', '') +
|
||||
'<td class="text-center px-2 py-1.5" onclick="event.stopPropagation()"><button onclick="runStrategyBacktest(\'' + s.version + '\')" class="px-2 py-0.5 bg-blue-600/60 hover:bg-blue-500 rounded text-xs">▶回测</button></td></tr>';
|
||||
};
|
||||
// 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] 取
|
||||
|
||||
Reference in New Issue
Block a user