Add instance nav prefs, env config UI, and PM2 restart.

P1-P4: configurable nav/section visibility in system settings, full .env editor with restart badges, password change, runtime hot overrides, and single-instance pm2 restart. Works in hub embed iframe.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-08 20:07:06 +08:00
parent d84a265b67
commit ef4b2f17ca
25 changed files with 1570 additions and 17 deletions
@@ -0,0 +1,12 @@
{# 系统设置 · 导航显示开关 #}
<div class="card settings-card settings-card--compact" id="display-prefs-card">
<h2>导航显示</h2>
<p class="settings-env-hint">以下开关控制顶栏导航与系统设置内区块是否显示,保存后立即生效。关键位监控、实盘下单、系统设置为固定项。</p>
<div id="display-prefs-form" class="display-prefs-form">
<div class="display-prefs-loading muted">加载中…</div>
</div>
<div class="settings-actions-row">
<button type="button" class="btn-primary btn-sm" id="display-prefs-save">保存导航设置</button>
<span class="settings-status-line" id="display-prefs-status"></span>
</div>
</div>
@@ -396,6 +396,9 @@
</div>
{% endif %}
</div>
{% if page == 'env_config' %}
{% include 'env_config_panel.html' %}
{% endif %}
{% if page == 'risk_policy' %}
{% include 'risk_policy_panel.html' %}
{% endif %}
+21 -6
View File
@@ -7,7 +7,7 @@
<link rel="stylesheet" href="/static/instance_theme_early.css?v=4">
<link rel="stylesheet" href="/static/account_risk_badge.css?v=4">
<link rel="stylesheet" href="/static/instance_page.css?v=4">
<link rel="stylesheet" href="/static/instance_theme.css?v=70">
<link rel="stylesheet" href="/static/instance_theme.css?v=71">
<script src="/static/account_risk_badge.js?v=4"></script>
<meta name="theme-color" content="#0b0d14">
<title>{{ exchange_display }} · 加密货币 | 交易监控复盘系统</title>
@@ -30,22 +30,33 @@
<nav class="top-nav embed-top-nav" aria-label="实例导航">
<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>
{% if not intraday_discipline %}
{% 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 %}
{% if not intraday_discipline and display.show_nav_strategy_records %}
<a href="/strategy/records" data-embed-tab="strategy_records" class="{% if initial_tab == 'strategy_records' %}active{% endif %}">策略交易记录</a>
{% endif %}
{% if display.show_nav_records %}
<a href="/records" data-embed-tab="records" class="{% if initial_tab == 'records' %}active{% endif %}">交易记录与复盘</a>
{% endif %}
{% if display.show_nav_stats %}
<a href="/stats" data-embed-tab="stats" class="{% if initial_tab == 'stats' %}active{% endif %}">统计分析</a>
{% if options_nav_visible %}
{% endif %}
{% if options_nav_visible and display.show_nav_options %}
<a href="/options" data-embed-tab="options" class="{% if initial_tab == 'options' %}active{% endif %}">期权</a>
{% endif %}
{% if display.show_nav_risk_policy %}
<a href="/risk_policy" data-embed-tab="risk_policy" class="{% if initial_tab == 'risk_policy' %}active{% endif %}">风控说明</a>
{% endif %}
{% if display.show_nav_env_config %}
<a href="/env_config" data-embed-tab="env_config" class="{% if initial_tab == 'env_config' %}active{% endif %}">env配置</a>
{% endif %}
<a href="/settings" data-embed-tab="settings" class="{% if initial_tab == 'settings' %}active{% endif %}">系统设置</a>
</nav>
<div id="embed-flash" class="flash" style="display:none" role="status"></div>
{% include 'instance_header_panel.html' %}
{% if initial_tab not in ('settings', 'risk_policy') and include_transfer_block %}
{% if initial_tab not in ('settings', 'risk_policy', 'env_config') and include_transfer_block %}
{% include 'instance_top_bar.html' %}
{% endif %}
@@ -89,7 +100,11 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
<script src="/static/strategy_roll.js?v=6"></script>
<script src="/static/key_monitor_form.js?v=2"></script>
{% include 'embed_boot_scripts.html' %}
<script src="/static/instance_live.js?v=3"></script>
<script src="/static/instance_embed.js?v=16"></script>
<script>
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
</script>
<script src="/static/instance_settings_prefs.js?v=1"></script>
<script src="/static/instance_live.js?v=4"></script>
<script src="/static/instance_embed.js?v=17"></script>
</body>
</html>
@@ -0,0 +1,16 @@
{# env配置:按功能分组,三列卡片布局 #}
<div class="env-config-page">
<div class="env-config-head card">
<h2>env 配置</h2>
<p class="settings-env-hint">读取并编辑本实例 <code>.env</code>。标注「保存即生效」的项会立即应用;标注「需重启」的项保存后请点「保存并重启」。</p>
<div class="env-config-toolbar">
<button type="button" class="btn-primary btn-sm" id="env-config-save">保存</button>
<button type="button" class="btn-secondary btn-sm" id="env-config-save-restart">保存并重启</button>
<button type="button" class="btn-secondary btn-sm" id="env-config-reload">重新加载</button>
<span class="settings-status-line" id="env-config-status"></span>
</div>
</div>
<div id="env-config-grid" class="env-config-grid">
<div class="env-config-loading muted">加载配置中…</div>
</div>
</div>
+23 -4
View File
@@ -17,7 +17,7 @@
<link rel="manifest" href="/static/icons/manifest.webmanifest">
<title>{{ exchange_display }} · 加密货币 | 交易监控复盘系统</title>
<link rel="stylesheet" href="/static/instance_page.css?v=1">
<link rel="stylesheet" href="/static/instance_theme.css?v=70">
<link rel="stylesheet" href="/static/instance_theme.css?v=71">
</head>
<body
@@ -55,22 +55,33 @@
<div class="top-nav">
<a href="/key_monitor" class="{% if page == 'key_monitor' %}active{% endif %}">关键位监控</a>
<a href="/trade" class="{% if page == 'trade' %}active{% endif %}">实盘下单</a>
{% if not intraday_discipline %}
{% 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 %}
{% if not intraday_discipline and display.show_nav_strategy_records %}
<a href="/strategy/records" class="{% if page == 'strategy_records' %}active{% endif %}">策略交易记录</a>
{% endif %}
{% if display.show_nav_records %}
<a href="/records" class="{% if page == 'records' %}active{% endif %}">交易记录与复盘</a>
{% endif %}
{% if display.show_nav_stats %}
<a href="/stats" class="{% if page == 'stats' %}active{% endif %}">统计分析</a>
{% if options_nav_visible %}
{% endif %}
{% if options_nav_visible and display.show_nav_options %}
<a href="/options" class="{% if page == 'options' %}active{% endif %}">期权</a>
{% endif %}
{% if display.show_nav_risk_policy %}
<a href="/risk_policy" class="{% if page == 'risk_policy' %}active{% endif %}">风控说明</a>
{% endif %}
{% if display.show_nav_env_config %}
<a href="/env_config" class="{% if page == 'env_config' %}active{% endif %}">env配置</a>
{% endif %}
<a href="/settings" class="{% if page == 'settings' %}active{% endif %}">系统设置</a>
</div>
{% with msg=get_flashed_messages() %}{% if msg %}<div class="flash">{{ msg[0] }}</div>{% endif %}{% endwith %}
{% include 'instance_header_panel.html' %}
{% if page not in ('settings', 'risk_policy', 'options') %}
{% if page not in ('settings', 'risk_policy', 'env_config', 'options') %}
{% include 'instance_top_bar.html' %}
{% endif %}
@@ -468,6 +479,10 @@
{% endif %}
</div>
{% if page == 'env_config' %}
{% include 'env_config_panel.html' %}
{% endif %}
{% if page == 'risk_policy' %}
{% include 'risk_policy_panel.html' %}
{% endif %}
@@ -2020,5 +2035,9 @@ setInterval(tickOrderHoldDurations, 1000);
tickOrderHoldDurations();
setInterval(refreshPriceSnapshotConditional, {{ price_refresh_seconds * 1000 }});
</script>
<script>
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
</script>
<script src="/static/instance_settings_prefs.js?v=1"></script>
</body>
</html>
@@ -0,0 +1,15 @@
{# 系统设置 · 账户密码 #}
<div class="card settings-subcard settings-subcard--ops" id="password-settings-card" data-settings-section="password">
<h3 class="settings-subcard-title">账户密码修改</h3>
<p class="settings-subcard-desc">修改网页登录账号密码,写入 <code>.env</code> 后需重启实例生效。</p>
<div class="settings-password-form">
<label>当前密码 <input type="password" id="pwd-old" autocomplete="current-password"></label>
<label>新用户名(可选) <input type="text" id="pwd-new-username" autocomplete="username"></label>
<label>新密码 <input type="password" id="pwd-new" autocomplete="new-password"></label>
<label>确认新密码 <input type="password" id="pwd-confirm" autocomplete="new-password"></label>
</div>
<div class="settings-actions-row">
<button type="button" class="btn-primary btn-sm" id="pwd-save-btn">保存密码</button>
<span class="settings-status-line" id="pwd-save-status"></span>
</div>
</div>
+15 -3
View File
@@ -1,19 +1,29 @@
{# 系统设置:资金划转 + 数据导出(顶栏资金与统计见 instance_header_panel #}
{# 系统设置:导航显示 + 账户密码 + 资金划转 + 数据导出 #}
<div class="settings-page settings-page--ops">
{% include 'display_prefs_panel.html' %}
{% if display.show_settings_password %}
{% include 'password_settings_panel.html' %}
{% endif %}
<div class="card settings-card settings-card--side-panel">
<div class="settings-side-subcards">
{% if instance_settings.options_settings_enabled %}
{% if instance_settings.options_settings_enabled and display.show_settings_options_swap %}
<div class="card settings-subcard settings-subcard--ops">
<h3 class="settings-subcard-title">币种兑换</h3>
{% include 'options_settings_swap.html' %}
</div>
{% endif %}
{% if instance_settings.options_settings_enabled and display.show_settings_options_transfer %}
<div class="card settings-subcard settings-subcard--ops">
<h3 class="settings-subcard-title">期权资金划转</h3>
{% include 'options_settings_transfer.html' %}
</div>
{% endif %}
{% if instance_settings.options_settings_enabled %}
{% include 'options_settings_panel.html' %}
{% endif %}
{% if instance_settings.show_transfer %}
{% if instance_settings.show_transfer and display.show_settings_transfer %}
<div class="card settings-subcard settings-subcard--ops">
<h3 class="settings-subcard-title">永续资金划转</h3>
<p class="settings-subcard-desc">子账户永续:资金账户与交易账户之间划转 USDT。</p>
@@ -21,6 +31,7 @@
</div>
{% endif %}
{% if display.show_settings_export %}
<div class="settings-side-export">
<div class="settings-side-export-head">
<span class="settings-side-export-label">数据导出</span>
@@ -33,6 +44,7 @@
<a href="/export/key_monitor_history">关键位历史</a>
</div>
</div>
{% endif %}
</div>
</div>
</div>