Add key monitor and live trade toggles to instance nav display prefs.

Defaults stay on; users can hide them like other top-bar tabs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-24 00:55:31 +08:00
parent ca499c6104
commit 87e92f1a5a
5 changed files with 26 additions and 5 deletions
@@ -9,6 +9,8 @@ DISPLAY_RUNTIME_PREFIX = "display."
DEFAULT_INSTANCE_DISPLAY: dict[str, bool] = {
"show_nav_dashboard": False,
"show_nav_key_monitor": True,
"show_nav_trade": True,
"show_nav_strategy": True,
"show_nav_strategy_records": True,
"show_nav_records": True,
@@ -28,6 +30,8 @@ DEFAULT_INSTANCE_DISPLAY: dict[str, bool] = {
DISPLAY_LABELS: dict[str, str] = {
"show_nav_dashboard": "数据看板",
"show_nav_key_monitor": "关键位监控",
"show_nav_trade": "实盘下单",
"show_nav_strategy": "策略交易",
"show_nav_strategy_records": "策略交易记录",
"show_nav_records": "交易记录与复盘",
@@ -47,6 +51,8 @@ DISPLAY_LABELS: dict[str, str] = {
NAV_TAB_ALLOWED: dict[str, str] = {
"dashboard": "show_nav_dashboard",
"key_monitor": "show_nav_key_monitor",
"trade": "show_nav_trade",
"strategy": "show_nav_strategy",
"strategy_records": "show_nav_strategy_records",
"records": "show_nav_records",
@@ -110,6 +116,8 @@ 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_key_monitor",
"show_nav_trade",
"show_nav_strategy",
"show_nav_strategy_records",
"show_nav_records",
@@ -1,7 +1,7 @@
{# 系统设置 · 导航显示开关(SSR 预渲染,保存仍走 API) #}
<div class="settings-tab-inner" id="display-prefs-card">
<h2>导航显示</h2>
<p class="settings-env-hint">以下开关控制顶栏导航与系统设置内区块是否显示,保存后立即生效.关键位监控,实盘下单,系统设置为固定项.</p>
<p class="settings-env-hint">以下开关控制顶栏导航与系统设置内区块是否显示,保存后立即生效.系统设置为固定项.</p>
<div id="display-prefs-form" class="display-prefs-form" data-prefs-ssr="1">
{% if display_meta %}
{% for group in display_meta %}
+2 -2
View File
@@ -31,8 +31,8 @@
</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="/key_monitor" data-embed-tab="key_monitor" class="{% if initial_tab == 'key_monitor' %}active{% endif %}">关键位监控</a>
<a href="/trade" data-embed-tab="trade" class="{% if initial_tab == 'trade' %}active{% 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 %}
<a href="/strategy" data-embed-tab="strategy" class="{% if initial_tab == 'strategy' %}active{% endif %}">策略交易</a>
{% endif %}
+2 -2
View File
@@ -118,8 +118,8 @@
</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="/key_monitor" class="{% if page == 'key_monitor' %}active{% endif %}">关键位监控</a>
<a href="/trade" class="{% if page == 'trade' %}active{% 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 %}
<a href="/strategy" class="{% if page in ('strategy', 'strategy_trend', 'strategy_roll') %}active{% endif %}">策略交易</a>
{% endif %}
@@ -21,6 +21,19 @@ class TestInstanceDisplayPrefs(unittest.TestCase):
prefs = normalize_display_prefs({"show_nav_stats": False})
self.assertFalse(tab_allowed("stats", prefs))
self.assertTrue(tab_allowed("trade", prefs))
self.assertTrue(tab_allowed("key_monitor", prefs))
def test_key_monitor_and_trade_nav_can_hide(self):
prefs = normalize_display_prefs(
{"show_nav_key_monitor": False, "show_nav_trade": False}
)
self.assertFalse(tab_allowed("key_monitor", prefs))
self.assertFalse(tab_allowed("trade", prefs))
on = normalize_display_prefs({})
self.assertTrue(on["show_nav_key_monitor"])
self.assertTrue(on["show_nav_trade"])
self.assertTrue(tab_allowed("key_monitor", on))
self.assertTrue(tab_allowed("trade", on))
def test_dashboard_nav_default_off(self):
prefs = normalize_display_prefs({})