/* 仪表盘 */ async function loadOverview() { try { const d = await api('/api/overview'); renderIndexes(d.indexes, d.stat); renderTop(d.top); renderHeat(d.heat); renderNews(d.news); renderWatch(d.watchlist); } catch (e) { $('#indexBox').innerHTML = '
加载失败:' + escapeHtml(e.message) + '
'; } } function renderIndexes(indexes, stat) { const cards = indexes.map(ix => { const cls = pctClass(ix.chg); return `
${ix.label}
${Number(ix.value).toFixed(2)}
${fmtPct(ix.chg)}
`; }).join(''); const s = stat || {}; $('#indexBox').innerHTML = cards + `
市场情绪
上涨
${s.up || 0}
下跌
${s.down || 0}
涨停
${s.limit_up || 0}
跌停
${s.limit_down || 0}
成交额
${fmtAmountYi(s.amount_yi)}
股票池 ${s.total || 0} 只 · 综合评分由 趋势/动量/技术/量能/消息/机构 六因子加权得出
`; } function renderTop(list) { if (!list || !list.length) { $('#topRecBox').innerHTML = '
暂无数据
'; return; } $('#topRecBox').innerHTML = ` ${list.map((it, i) => ``).join('')}
排名股票现价今日评分评级推荐理由
`; } function renderHeat(heat) { if (!heat || !heat.length) { $('#heatBox').innerHTML = '
暂无数据
'; return; } const max = Math.max(...heat.map(h => Math.abs(h.chg)), 0.01); $('#heatBox').innerHTML = heat.map(h => { const w = Math.min(100, Math.abs(h.chg) / max * 100); const cls = pctClass(h.chg); return `
${escapeHtml(h.industry)} (${h.cnt}) ${fmtPct(h.chg)}
`; }).join(''); } function renderNews(news) { if (!news || !news.length) { $('#newsBox').innerHTML = '
暂无数据
'; return; } $('#newsBox').innerHTML = news.map(n => `
${escapeHtml(n.title)}
${n.category} ${n.sentiment > 0 ? '利好' : n.sentiment < 0 ? '利空' : '中性'} ${escapeHtml(n.source)}${n.publish_date}
`).join(''); } function renderWatch(list) { if (!list || !list.length) { $('#watchBox').innerHTML = `
暂无自选股
去股票池添加 →
`; return; } $('#watchBox').innerHTML = ` ${list.map(it => ``).join('')}
股票现价今日评分评级
`; } loadOverview();