diff --git a/lib/instance/instance_display_prefs_lib.py b/lib/instance/instance_display_prefs_lib.py index 6c767b4..1601edb 100644 --- a/lib/instance/instance_display_prefs_lib.py +++ b/lib/instance/instance_display_prefs_lib.py @@ -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", diff --git a/lib/instance/templates/display_prefs_panel.html b/lib/instance/templates/display_prefs_panel.html index 05a6622..38a744b 100644 --- a/lib/instance/templates/display_prefs_panel.html +++ b/lib/instance/templates/display_prefs_panel.html @@ -1,7 +1,7 @@ {# 系统设置 · 导航显示开关(SSR 预渲染,保存仍走 API) #}

导航显示

-

以下开关控制顶栏导航与系统设置内区块是否显示,保存后立即生效.关键位监控,实盘下单,系统设置为固定项.

+

以下开关控制顶栏导航与系统设置内区块是否显示,保存后立即生效.系统设置为固定项.

{% if display_meta %} {% for group in display_meta %} diff --git a/lib/instance/templates/embed_shell.html b/lib/instance/templates/embed_shell.html index 7b83572..f3e756f 100644 --- a/lib/instance/templates/embed_shell.html +++ b/lib/instance/templates/embed_shell.html @@ -31,8 +31,8 @@
- 关键位监控 - 实盘下单 + + {% if not intraday_discipline and display.show_nav_strategy %} 策略交易 {% endif %} diff --git a/tests/test_instance_display_env_settings.py b/tests/test_instance_display_env_settings.py index eb7e3e4..97c7dbc 100644 --- a/tests/test_instance_display_env_settings.py +++ b/tests/test_instance_display_env_settings.py @@ -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({})