feat(hub): add data dashboard and AI chat with session history

Add /dashboard with daily PnL overview and loss alerts. Extend AI coach chat with history sidebar, delete/switch sessions, message copy, and trading vs general bot modes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-11 10:42:33 +08:00
parent a45a3b18e2
commit 582ada7e60
11 changed files with 1479 additions and 55 deletions
+70 -19
View File
@@ -16,6 +16,7 @@
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Orbitron:wght@500;600;700&display=swap" rel="stylesheet" media="print" onload="this.media='all'" />
<noscript><link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Orbitron:wght@500;600;700&display=swap" rel="stylesheet" /></noscript>
<link rel="stylesheet" href="/assets/app.css?v=20260609-hub-funds-fold" />
<link rel="stylesheet" href="/assets/dashboard.css?v=20260611-hub-dashboard" />
</head>
<body>
<div class="app-bg" aria-hidden="true"></div>
@@ -48,6 +49,7 @@
<a href="/monitor" id="nav-monitor">监控区</a>
<a href="/market" id="nav-market">行情区</a>
<a href="/archive" id="nav-archive">币种档案</a>
<a href="/dashboard" id="nav-dashboard">数据看板</a>
<a href="/ai" id="nav-ai">AI 教练</a>
<a href="/settings" id="nav-settings">系统设置</a>
</nav>
@@ -312,6 +314,39 @@
</div>
</div>
<div id="page-dashboard" class="page hidden">
<div class="dash-bg-grid" aria-hidden="true"></div>
<div class="dash-bg-glow dash-bg-glow-a" aria-hidden="true"></div>
<div class="dash-bg-glow dash-bg-glow-b" aria-hidden="true"></div>
<div class="dash-wrap">
<div class="dash-head">
<div>
<h1><span class="dash-head-tag">DASH</span>数据看板</h1>
<p class="page-desc">四户当日总览 · 分户明细 · 平仓流水 · 每 60 秒刷新</p>
</div>
<div class="dash-head-meta">
<div><span class="dash-pulse-dot" aria-hidden="true"></span><strong>LIVE</strong> · 交易日 <span id="dash-trading-day"></span></div>
<div>更新 <span id="dash-updated-at"></span></div>
<button type="button" id="dash-btn-refresh" class="ghost" style="margin-top:8px">立即刷新</button>
</div>
</div>
<div id="dash-alert-banner" class="dash-alert-banner" role="alert">
<strong>⚠ 风险预警</strong>
<span id="dash-alert-banner-text"></span>
</div>
<div id="dash-kpi-row" class="dash-kpi-row"></div>
<section class="dash-section">
<div class="dash-section-head">分户明细 · ACCOUNTS</div>
<div class="dash-section-body"><div id="dash-accounts" class="dash-ac-grid"></div></div>
</section>
<section class="dash-section">
<div class="dash-section-head">平仓明细 · CLOSED TRADES</div>
<div class="dash-section-body" id="dash-trades-body"></div>
</section>
<p id="dash-status" class="dash-status"></p>
</div>
</div>
<div id="instance-frame-shell" class="instance-frame-shell hidden" aria-hidden="true">
<div class="instance-frame-toolbar">
<button type="button" id="instance-frame-back" class="ghost">← 返回监控</button>
@@ -408,10 +443,11 @@
<div id="page-ai" class="page hidden">
<div class="page-head">
<h1><span class="head-tag">AI</span> 教练</h1>
<p class="page-desc">四户今日总结 · 口语化陪聊(单会话,点「新开对话」清空上下文)</p>
<p class="page-desc">四户今日总结 · 交易教练 / 普通聊天 · 右侧可回看历史会话</p>
</div>
<div class="ai-mobile-tabs" role="tablist" aria-label="AI 教练视图">
<button type="button" class="ai-mobile-tab is-active" data-ai-tab="chat" role="tab" aria-selected="true">聊天</button>
<button type="button" class="ai-mobile-tab" data-ai-tab="history" role="tab" aria-selected="false">历史</button>
<button type="button" class="ai-mobile-tab" data-ai-tab="summary" role="tab" aria-selected="false">今日总结</button>
</div>
<div class="ai-layout" data-ai-mobile-tab="chat">
@@ -428,26 +464,40 @@
</div>
</section>
<section class="ai-panel ai-chat-panel" data-ai-panel="chat">
<div class="ai-panel-head">
<h2 id="ai-chat-title">聊天</h2>
<div class="ai-panel-actions">
<button type="button" id="btn-ai-chat-new" class="primary">新开对话</button>
</div>
<div class="ai-bot-bar" role="tablist" aria-label="聊天机器人">
<button type="button" class="ai-bot-tab is-active" data-bot="trading" role="tab" aria-selected="true">交易教练</button>
<button type="button" class="ai-bot-tab" data-bot="general" role="tab" aria-selected="false">普通聊天</button>
</div>
<div id="ai-chat-messages" class="ai-panel-scroll ai-chat-messages" aria-live="polite"></div>
<form id="ai-chat-form" class="ai-chat-form">
<div class="ai-chat-compose">
<textarea id="ai-chat-input" rows="2" placeholder="聊聊行情、心态、纪律、执行…" autocomplete="off"></textarea>
<div class="ai-chat-compose-actions">
<label class="ai-chat-upload-btn" title="上传图片或 txt/md/json 文档">
<input type="file" id="ai-chat-files" accept="image/*,.txt,.md,.markdown,.json" multiple hidden />
附件
</label>
<span id="ai-chat-files-label" class="ai-chat-files-label"></span>
<button type="submit" id="btn-ai-chat-send" class="primary">发送</button>
<div class="ai-chat-split">
<div class="ai-chat-main">
<div class="ai-panel-head">
<h2 id="ai-chat-title">聊天</h2>
<div class="ai-panel-actions">
<button type="button" id="btn-ai-chat-new" class="primary">新开对话</button>
</div>
</div>
<div id="ai-chat-messages" class="ai-panel-scroll ai-chat-messages" aria-live="polite"></div>
<form id="ai-chat-form" class="ai-chat-form">
<div class="ai-chat-compose">
<textarea id="ai-chat-input" rows="2" placeholder="聊聊行情、心态、纪律、执行…" autocomplete="off"></textarea>
<div class="ai-chat-compose-actions">
<label class="ai-chat-upload-btn" title="上传图片或 txt/md/json 文档">
<input type="file" id="ai-chat-files" accept="image/*,.txt,.md,.markdown,.json" multiple hidden />
附件
</label>
<span id="ai-chat-files-label" class="ai-chat-files-label"></span>
<button type="submit" id="btn-ai-chat-send" class="primary">发送</button>
</div>
</div>
</form>
</div>
</form>
<aside class="ai-chat-history-panel" aria-label="聊天历史">
<div class="ai-chat-history-head">
<h3>聊天历史</h3>
</div>
<div id="ai-chat-history-list" class="ai-panel-scroll ai-chat-history-list" role="list"></div>
</aside>
</div>
</section>
</div>
</div>
@@ -510,7 +560,8 @@
<script src="/assets/chart.js?v=20260609-market-day-split"></script>
<script src="/assets/archive.js?v=20260608-hub-archive-history"></script>
<script src="/assets/funds.js?v=20260609-hub-funds-fold"></script>
<script src="/assets/dashboard.js?v=20260611-hub-dashboard"></script>
<script src="/assets/ai_review_render.js?v=2"></script>
<script src="/assets/app.js?v=20260609-hub-funds-ai"></script>
<script src="/assets/app.js?v=20260611-hub-dashboard"></script>
</body>
</html>