fix(hub): add section icons and color PnL in AI summary table
Show emoji headings for overview, accounts, alerts, and data notes; apply green/red styling to table PnL columns. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2972,43 +2972,20 @@
|
||||
return renderHubMarkdown(text);
|
||||
}
|
||||
|
||||
const AI_EX_SVG = {
|
||||
binance:
|
||||
'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><rect width="24" height="24" rx="5" fill="#F0B90B"/><path fill="#1E2329" d="M12 4.5l2.2 2.2L12 8.9 9.8 6.7 12 4.5zm0 14.6l2.2-2.2L12 15.1l-2.2 2.2 2.2 2.2zM4.5 12l2.2-2.2L8.9 12l-2.2 2.2L4.5 12zm14.6 0l2.2-2.2L15.1 12l2.2-2.2 2.2 2.2z"/></svg>',
|
||||
okx:
|
||||
'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><rect width="24" height="24" rx="5" fill="#000"/><rect x="5" y="5" width="6" height="6" fill="#fff"/><rect x="13" y="5" width="6" height="6" fill="#fff"/><rect x="5" y="13" width="6" height="6" fill="#fff"/><rect x="13" y="13" width="6" height="6" fill="#fff"/></svg>',
|
||||
gate:
|
||||
'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><rect width="24" height="24" rx="5" fill="#2354E6"/><path fill="#fff" d="M7 17V7h4.2c2.2 0 3.6 1.1 3.6 2.9 0 1.2-.6 2.1-1.6 2.5 1.2.4 2 1.4 2 2.8 0 2-1.5 3.1-3.8 3.1H7zm2.5-2.1h1.5c1.1 0 1.7-.5 1.7-1.3s-.6-1.3-1.7-1.3H9.5v2.6zm0-4.4h1.4c1 0 1.5-.4 1.5-1.2s-.5-1.2-1.5-1.2H9.5v2.4z"/></svg>',
|
||||
gate_bot:
|
||||
'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><rect width="24" height="24" rx="5" fill="#17E6A1"/><path fill="#102820" d="M7 17V7h4.2c2.2 0 3.6 1.1 3.6 2.9 0 1.2-.6 2.1-1.6 2.5 1.2.4 2 1.4 2 2.8 0 2-1.5 3.1-3.8 3.1H7zm2.5-2.1h1.5c1.1 0 1.7-.5 1.7-1.3s-.6-1.3-1.7-1.3H9.5v2.6zm0-4.4h1.4c1 0 1.5-.4 1.5-1.2s-.5-1.2-1.5-1.2H9.5v2.4z"/></svg>',
|
||||
other:
|
||||
'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><rect width="24" height="24" rx="5" fill="var(--border-soft)"/><circle cx="12" cy="12" r="3" fill="var(--muted)"/></svg>',
|
||||
};
|
||||
|
||||
function resolveExchangeIconId(key, name) {
|
||||
const k = String(key || "").toLowerCase();
|
||||
const n = String(name || "").toLowerCase();
|
||||
if (k === "gate_bot" || k.includes("gate_bot") || n.includes("趋势") || n.includes("gate_bot"))
|
||||
return "gate_bot";
|
||||
if (k === "binance" || k.includes("binance") || n.includes("币安")) return "binance";
|
||||
if (k === "okx" || k.includes("okx")) return "okx";
|
||||
if (k === "gate" || k.includes("gate") || n.includes("gate")) return "gate";
|
||||
return "other";
|
||||
function enhanceHubSummaryMarkdown(md) {
|
||||
let out = String(md || "");
|
||||
out = out.replace(/\*\*今日交易总结(([^)]+))\*\*/g, "# 📋 今日交易总结($1)");
|
||||
out = out.replace(/\*\*1\.\s*(?:📊\s*)?总览\*\*/g, "## 1. 📊 总览");
|
||||
out = out.replace(/\*\*2\.\s*(?:👥\s*)?分户明细\*\*/g, "## 2. 👥 分户明细");
|
||||
out = out.replace(/\*\*3\.\s*(?:⚠️\s*)?需关注\*\*/g, "## 3. ⚠️ 需关注");
|
||||
out = out.replace(/\*\*4\.\s*(?:ℹ️\s*)?数据说明\*\*/g, "## 4. ℹ️ 数据说明");
|
||||
return out;
|
||||
}
|
||||
|
||||
function hubExchangeIconHtml(key, name) {
|
||||
const id = resolveExchangeIconId(key, name);
|
||||
const title =
|
||||
id === "binance"
|
||||
? "Binance"
|
||||
: id === "okx"
|
||||
? "OKX"
|
||||
: id === "gate_bot"
|
||||
? "Gate Bot"
|
||||
: id === "gate"
|
||||
? "Gate"
|
||||
: "";
|
||||
return `<span class="ai-ex-icon ai-ex-${id}" title="${esc(title)}">${AI_EX_SVG[id] || AI_EX_SVG.other}</span>`;
|
||||
function aiPnlCellHtml(v, digits) {
|
||||
const cls = aiPnlClass(v);
|
||||
const valCls = cls ? ` ai-stat-val ${cls}` : " ai-stat-val";
|
||||
return `<span class="${valCls.trim()}">${aiPnlSigned(v, digits)}</span>`;
|
||||
}
|
||||
|
||||
function aiAccountStatusClass(status) {
|
||||
@@ -3038,11 +3015,11 @@
|
||||
const statusCls = aiAccountStatusClass(ac.status);
|
||||
return (
|
||||
"<tr>" +
|
||||
`<td class="ai-ac-name">${hubExchangeIconHtml(ac.key, ac.name)}<span>${esc(ac.name || "—")}</span></td>` +
|
||||
`<td class="ai-ac-name">${esc(ac.name || "—")}</td>` +
|
||||
`<td class="${statusCls}">${esc(ac.status || "—")}</td>` +
|
||||
`<td class="${aiPnlClass(closedPnl)}">${aiPnlSigned(closedPnl, 2)}</td>` +
|
||||
`<td>${aiPnlCellHtml(closedPnl, 2)}</td>` +
|
||||
`<td>${Number(ac.closed_count) || 0}</td>` +
|
||||
`<td class="${aiPnlClass(floatPnl)}">${aiPnlSigned(floatPnl, 2)}</td>` +
|
||||
`<td>${aiPnlCellHtml(floatPnl, 2)}</td>` +
|
||||
`<td class="ai-ac-remark">${esc(remark)}</td>` +
|
||||
"</tr>"
|
||||
);
|
||||
@@ -3052,9 +3029,9 @@
|
||||
}
|
||||
|
||||
function renderAiSummaryBody(contentMd, snapshot) {
|
||||
const md = String(contentMd || "");
|
||||
const sec2 = /\*\*2\.\s*分户明细\*\*/;
|
||||
const sec3 = /\*\*3\.\s*需关注\*\*/;
|
||||
const md = enhanceHubSummaryMarkdown(contentMd);
|
||||
const sec2 = /##\s*2\.\s*👥\s*分户明细/;
|
||||
const sec3 = /##\s*3\.\s*⚠️\s*需关注/;
|
||||
const i2 = md.search(sec2);
|
||||
const i3 = md.search(sec3);
|
||||
const tableHtml = renderAiAccountTable(snapshot);
|
||||
|
||||
Reference in New Issue
Block a user