feat(instance): add exchange account ledger tab with SSE sync

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-10 09:51:45 +08:00
parent 425fc701bc
commit 245b85ad27
26 changed files with 1994 additions and 5 deletions
@@ -9,6 +9,7 @@ DISPLAY_RUNTIME_PREFIX = "display."
DEFAULT_INSTANCE_DISPLAY: dict[str, bool] = {
"show_nav_dashboard": False,
"show_nav_account_ledger": False,
"show_nav_key_monitor": True,
"show_nav_trade": True,
"show_nav_strategy": True,
@@ -30,6 +31,7 @@ DEFAULT_INSTANCE_DISPLAY: dict[str, bool] = {
DISPLAY_LABELS: dict[str, str] = {
"show_nav_dashboard": "数据看板",
"show_nav_account_ledger": "账户流水",
"show_nav_key_monitor": "关键位监控",
"show_nav_trade": "实盘下单",
"show_nav_strategy": "策略交易",
@@ -51,6 +53,7 @@ DISPLAY_LABELS: dict[str, str] = {
NAV_TAB_ALLOWED: dict[str, str] = {
"dashboard": "show_nav_dashboard",
"account_ledger": "show_nav_account_ledger",
"key_monitor": "show_nav_key_monitor",
"trade": "show_nav_trade",
"strategy": "show_nav_strategy",
@@ -116,6 +119,7 @@ def tab_allowed(tab: str, display: Optional[dict[str, bool]] = None) -> bool:
def display_meta_for_ui() -> list[dict[str, Any]]:
nav_keys = [
"show_nav_dashboard",
"show_nav_account_ledger",
"show_nav_key_monitor",
"show_nav_trade",
"show_nav_strategy",
+2
View File
@@ -12,6 +12,7 @@ from jinja2 import ChoiceLoader, FileSystemLoader
EMBED_TABS: tuple[str, ...] = (
"dashboard",
"account_ledger",
"key_monitor",
"trade",
"strategy",
@@ -31,6 +32,7 @@ PATH_TO_EMBED_TAB: dict[str, str] = {
"/": "trade",
"/trade": "trade",
"/dashboard": "dashboard",
"/account_ledger": "account_ledger",
"/key_monitor": "key_monitor",
"/strategy": "strategy",
"/strategy/trend": "strategy",
@@ -10,7 +10,7 @@
<div class="display-prefs-checks">
{% for item in group.entries %}
<label class="chk-label">
<input type="checkbox" data-pref-key="{{ item.key }}"{% if item.key in ('show_nav_dashboard', 'show_nav_system_guide') %}{% if display.get(item.key) %} checked{% endif %}{% elif display.get(item.key, true) %} checked{% endif %}>
<input type="checkbox" data-pref-key="{{ item.key }}"{% if item.key in ('show_nav_dashboard', 'show_nav_account_ledger', 'show_nav_system_guide') %}{% if display.get(item.key) %} checked{% endif %}{% elif display.get(item.key, true) %} checked{% endif %}>
{{ item.label }}
</label>
{% endfor %}
@@ -119,6 +119,8 @@
<div class="grid">
{% if page == 'dashboard' %}
{% include 'dashboard_panel.html' %}
{% elif page == 'account_ledger' %}
{% include 'account_ledger_panel.html' %}
{% elif page == 'key_monitor' %}
{% include 'key_monitor_panel.html' %}
{% elif page == 'trade' %}
+5 -2
View File
@@ -32,6 +32,7 @@
</div>
<nav class="top-nav embed-top-nav" aria-label="实例导航">
<a href="/dashboard" data-embed-tab="dashboard" class="{% if initial_tab == 'dashboard' %}active{% endif %}"{% if not display.show_nav_dashboard %} style="display:none"{% endif %}>数据看板</a>
<a href="/account_ledger" data-embed-tab="account_ledger" class="{% if initial_tab == 'account_ledger' %}active{% endif %}"{% if not display.show_nav_account_ledger %} style="display:none"{% endif %}>账户流水</a>
<a href="/key_monitor" data-embed-tab="key_monitor" class="{% if initial_tab == 'key_monitor' %}active{% endif %}"{% if not display.show_nav_key_monitor %} style="display:none"{% endif %}>关键位监控</a>
<a href="/trade" data-embed-tab="trade" class="{% if initial_tab == 'trade' %}active{% endif %}"{% if not display.show_nav_trade %} style="display:none"{% endif %}>实盘下单</a>
{% if not intraday_discipline and display.show_nav_strategy %}
@@ -111,6 +112,7 @@
<p class="inst-mobile-more-hint">次要页面 · 完整界面请用电脑</p>
<nav class="inst-mobile-more-nav" aria-label="更多页面">
<a href="/dashboard" data-embed-tab="dashboard"{% if not display.show_nav_dashboard %} style="display:none"{% endif %}>数据看板</a>
<a href="/account_ledger" data-embed-tab="account_ledger"{% if not display.show_nav_account_ledger %} style="display:none"{% endif %}>账户流水</a>
{% if display.show_nav_records %}
<a href="/records" data-embed-tab="records">交易记录</a>
{% endif %}
@@ -164,12 +166,13 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
<script src="/static/records_review_page.js?v=4"></script>
<script src="/static/options_expiry_countdown.js?v=1"></script>
<script src="/static/instance_dashboard.js?v=5"></script>
<script src="/static/account_ledger.js?v=1"></script>
<script>
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
</script>
<script src="/static/instance_settings_prefs.js?v=18"></script>
<script src="/static/instance_settings_prefs.js?v=19"></script>
<script src="/static/instance_live.js?v=6"></script>
<script src="/static/instance_embed.js?v=30"></script>
<script src="/static/instance_embed.js?v=31"></script>
<script src="/static/instance_mobile_nav.js?v=2"></script>
</body>
</html>
+10 -1
View File
@@ -155,6 +155,7 @@
</div>
<div class="top-nav">
<a href="/dashboard" data-embed-tab="dashboard" class="{% if page == 'dashboard' %}active{% endif %}"{% if not display.show_nav_dashboard %} style="display:none"{% endif %}>数据看板</a>
<a href="/account_ledger" data-embed-tab="account_ledger" class="{% if page == 'account_ledger' %}active{% endif %}"{% if not display.show_nav_account_ledger %} style="display:none"{% endif %}>账户流水</a>
<a href="/key_monitor" class="{% if page == 'key_monitor' %}active{% endif %}"{% if not display.show_nav_key_monitor %} style="display:none"{% endif %}>关键位监控</a>
<a href="/trade" class="{% if page == 'trade' %}active{% endif %}"{% if not display.show_nav_trade %} style="display:none"{% endif %}>实盘下单</a>
{% if not intraday_discipline and display.show_nav_strategy %}
@@ -197,6 +198,8 @@
<div class="grid">
{% if page == 'dashboard' %}
{% include 'dashboard_panel.html' %}
{% elif page == 'account_ledger' %}
{% include 'account_ledger_panel.html' %}
{% elif page == 'key_monitor' %}
{% include 'key_monitor_panel.html' %}
{% elif page == 'trade' %}
@@ -2028,6 +2031,7 @@ setInterval(refreshPriceSnapshotConditional, {{ price_refresh_seconds * 1000 }})
<script src="/static/records_review_page.js?v=4"></script>
<script src="/static/options_expiry_countdown.js?v=1"></script>
<script src="/static/instance_dashboard.js?v=5"></script>
<script src="/static/account_ledger.js?v=1"></script>
<script>
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
{% if page == 'dashboard' %}
@@ -2035,7 +2039,12 @@ document.addEventListener("DOMContentLoaded", function () {
if (window.InstanceDashboard) InstanceDashboard.init(true);
});
{% endif %}
{% if page == 'account_ledger' %}
document.addEventListener("DOMContentLoaded", function () {
if (window.AccountLedgerPage) AccountLedgerPage.boot();
});
{% endif %}
</script>
<script src="/static/instance_settings_prefs.js?v=18"></script>
<script src="/static/instance_settings_prefs.js?v=19"></script>
</body>
</html>