系统设置改为 Tab 布局,并加大备份区块内边距。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-04 06:54:01 +08:00
parent a983fff6e0
commit 1300dbfd39
4 changed files with 234 additions and 115 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}期权中控{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=5">
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=6">
</head>
<body class="{% if request.path.startswith('/login') %}page-login{% elif request.path.startswith('/desk') %}page-desk{% elif request.path.startswith('/stats') %}page-stats{% elif request.path == '/' %}page-dashboard{% endif %}">
{% if session.get('logged_in') %}
+126 -108
View File
@@ -1,129 +1,147 @@
{% extends "base.html" %}
{% block title %}系统设置 · 期权中控{% endblock %}
{% block body %}
{% set _tab = (request.args.get('tab') or 'account').strip() %}
{% if _tab not in ('account', 'wechat', 'backup') %}{% set _tab = 'account' %}{% endif %}
<section class="page-head settings-head">
<div>
<p class="settings-eyebrow">Hub Settings</p>
<h1>系统设置</h1>
<p class="muted settings-lead">账号与中控告警在此维护,保存后立即生效。</p>
<p class="muted settings-lead">账号、告警与备份在此维护;保存后立即生效。</p>
</div>
</section>
<div class="settings-grid">
<section class="panel settings-card settings-card--account">
<div class="settings-card-head">
<span class="settings-badge">Account</span>
<h2>登录账号</h2>
<p class="muted">修改后立即写入 <code>.env</code>,无需重启。</p>
</div>
<form method="post" class="stack settings-form" autocomplete="off" data-lpignore="true" data-1p-ignore="true">
<input type="hidden" name="form_action" value="account">
<div class="settings-field">
<span class="settings-label">当前用户名</span>
<div class="settings-readonly">{{ current_username }}</div>
</div>
<label class="settings-field">当前密码
<input type="password" name="current_password" required autocomplete="new-password" placeholder="验证身份后才能保存">
</label>
<div class="settings-divider"></div>
<label class="settings-field">新用户名
<input type="text" name="new_username" value="{{ current_username }}" required autocomplete="off" minlength="2" maxlength="64">
</label>
<div class="settings-row-2">
<label class="settings-field">新密码
<input type="password" name="new_password" autocomplete="new-password" minlength="6" placeholder="至少 6 位,不改可留空">
</label>
<label class="settings-field">确认新密码
<input type="password" name="confirm_password" autocomplete="new-password" minlength="6" placeholder="再次输入">
</label>
</div>
<button type="submit" class="settings-primary">保存账号</button>
</form>
</section>
<div class="settings-shell panel">
<input type="radio" name="hub-settings-tab" id="hub-set-account" class="settings-tab-radio"{% if _tab == 'account' %} checked{% endif %}>
<input type="radio" name="hub-settings-tab" id="hub-set-wechat" class="settings-tab-radio"{% if _tab == 'wechat' %} checked{% endif %}>
<input type="radio" name="hub-settings-tab" id="hub-set-backup" class="settings-tab-radio"{% if _tab == 'backup' %} checked{% endif %}>
<section class="panel settings-card settings-card--wechat">
<div class="settings-card-head">
<span class="settings-badge settings-badge--alert">Notify</span>
<h2>企业微信告警</h2>
<p class="muted">中控专用:客户端离线 / 故障 / 恢复时推送,与交易机通知分开。</p>
</div>
<form method="post" class="stack settings-form" autocomplete="off">
<label class="settings-switch">
<input type="checkbox" name="wechat_enabled" value="1"{% if wechat.enabled %} checked{% endif %}>
<span class="settings-switch-ui" aria-hidden="true"></span>
<span class="settings-switch-text">
<strong>启用企业微信推送</strong>
<small>关闭后后台仍巡检,但不发消息</small>
</span>
</label>
<div class="settings-row-2">
<label class="settings-field">告警冷却(秒)
<input type="number" name="alert_cooldown_sec" value="{{ wechat.cooldown_sec }}" min="60" max="86400" step="1">
</label>
<label class="settings-field">连续失败阈值
<input type="number" name="health_fail_threshold" value="{{ wechat.fail_threshold }}" min="1" max="20" step="1">
</label>
</div>
<p class="field-hint settings-hint">连续拉取失败达到阈值后才告警,默认 2 次;同一机器在冷却期内不重复推送。</p>
<label class="settings-field">Webhook 地址
<input type="url" name="wechat_webhook" value="{{ wechat.webhook }}" placeholder="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=..." autocomplete="off">
</label>
<div class="settings-actions">
<button type="submit" name="form_action" value="wechat" class="settings-primary">保存告警配置</button>
<button type="submit" name="form_action" value="wechat_test" class="btn-secondary">发送测试消息</button>
</div>
</form>
</section>
<div class="settings-tabs" role="tablist" aria-label="系统设置分类">
<label for="hub-set-account" class="settings-tab-btn" role="tab">登录账号</label>
<label for="hub-set-wechat" class="settings-tab-btn" role="tab">企业微信</label>
<label for="hub-set-backup" class="settings-tab-btn" role="tab">备份恢复</label>
</div>
<section class="panel settings-card settings-card--backup" style="grid-column:1/-1">
<div class="settings-card-head">
<span class="settings-badge">Backup</span>
<h2>备份恢复</h2>
<p class="muted">每天北京时间 03:00 自动备份,保留最近 10 天。中控可下载本机与各客户端备份;客户端仅能下载自己的。</p>
</div>
<div class="backup-block">
<div class="backup-block-head">
<h3>中控备份</h3>
<p class="muted field-hint">目录 <code id="hub-backup-dir">/root/crypto_okx_hub_backups</code> · 含 <code>.env</code> 与 <code>hub.db</code></p>
<div class="settings-actions">
<button type="button" class="settings-primary" id="hub-backup-create">立即备份</button>
<button type="button" class="btn-secondary" id="hub-backup-refresh">刷新</button>
<span class="muted" id="hub-backup-status" style="font-size:.8rem"></span>
<div class="settings-panels">
<section class="settings-panel settings-panel--account" role="tabpanel">
<div class="settings-card-head">
<span class="settings-badge">Account</span>
<h2>登录账号</h2>
<p class="muted">修改后立即写入 <code>.env</code>,无需重启。</p>
</div>
<form method="post" class="stack settings-form" autocomplete="off" data-lpignore="true" data-1p-ignore="true">
<input type="hidden" name="form_action" value="account">
<input type="hidden" name="return_tab" value="account">
<div class="settings-field">
<span class="settings-label">当前用户名</span>
<div class="settings-readonly">{{ current_username }}</div>
</div>
</div>
<div class="table-wrap">
<table class="backup-table">
<thead><tr><th>文件</th><th>时间</th><th>大小</th><th>操作</th></tr></thead>
<tbody id="hub-backup-body"><tr><td colspan="4" class="muted">加载中…</td></tr></tbody>
</table>
</div>
</div>
<div class="backup-block" style="margin-top:18px">
<div class="backup-block-head">
<h3>客户端备份</h3>
<p class="muted field-hint">经 Bridge 拉取各机备份列表,可下载到本地</p>
<div class="settings-actions">
<label class="settings-field" style="margin:0;min-width:12rem">
客户端
<select id="client-backup-instance"></select>
<label class="settings-field">当前密码
<input type="password" name="current_password" required autocomplete="new-password" placeholder="验证身份后才能保存">
</label>
<div class="settings-divider"></div>
<label class="settings-field">新用户名
<input type="text" name="new_username" value="{{ current_username }}" required autocomplete="off" minlength="2" maxlength="64">
</label>
<div class="settings-row-2">
<label class="settings-field">新密码
<input type="password" name="new_password" autocomplete="new-password" minlength="6" placeholder="至少 6 位,不改可留空">
</label>
<button type="button" class="btn-secondary" id="client-backup-refresh">刷新</button>
<span class="muted" id="client-backup-status" style="font-size:.8rem"></span>
<label class="settings-field">确认新密码
<input type="password" name="confirm_password" autocomplete="new-password" minlength="6" placeholder="再次输入">
</label>
</div>
<button type="submit" class="settings-primary">保存账号</button>
</form>
</section>
<section class="settings-panel settings-panel--wechat" role="tabpanel">
<div class="settings-card-head">
<span class="settings-badge settings-badge--alert">Notify</span>
<h2>企业微信告警</h2>
<p class="muted">中控专用:客户端离线 / 故障 / 恢复时推送,与交易机通知分开。</p>
</div>
<form method="post" class="stack settings-form" autocomplete="off">
<input type="hidden" name="return_tab" value="wechat">
<label class="settings-switch">
<input type="checkbox" name="wechat_enabled" value="1"{% if wechat.enabled %} checked{% endif %}>
<span class="settings-switch-ui" aria-hidden="true"></span>
<span class="settings-switch-text">
<strong>启用企业微信推送</strong>
<small>关闭后后台仍巡检,但不发消息</small>
</span>
</label>
<div class="settings-row-2">
<label class="settings-field">告警冷却(秒)
<input type="number" name="alert_cooldown_sec" value="{{ wechat.cooldown_sec }}" min="60" max="86400" step="1">
</label>
<label class="settings-field">连续失败阈值
<input type="number" name="health_fail_threshold" value="{{ wechat.fail_threshold }}" min="1" max="20" step="1">
</label>
</div>
<p class="field-hint settings-hint">连续拉取失败达到阈值后才告警,默认 2 次;同一机器在冷却期内不重复推送。</p>
<label class="settings-field">Webhook 地址
<input type="url" name="wechat_webhook" value="{{ wechat.webhook }}" placeholder="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=..." autocomplete="off">
</label>
<div class="settings-actions">
<button type="submit" name="form_action" value="wechat" class="settings-primary">保存告警配置</button>
<button type="submit" name="form_action" value="wechat_test" class="btn-secondary">发送测试消息</button>
</div>
</form>
</section>
<section class="settings-panel settings-panel--backup" role="tabpanel">
<div class="settings-card-head">
<span class="settings-badge">Backup</span>
<h2>备份恢复</h2>
<p class="muted">每天北京时间 03:00 自动备份,保留最近 10 天。中控可下载本机与各客户端备份;客户端仅能下载自己的。</p>
</div>
<div class="settings-backup-body">
<div class="backup-block">
<div class="backup-block-head">
<h3>中控备份</h3>
<p class="muted field-hint">目录 <code id="hub-backup-dir">/root/crypto_okx_hub_backups</code> · 含 <code>.env</code> 与 <code>hub.db</code></p>
<div class="settings-actions">
<button type="button" class="settings-primary" id="hub-backup-create">立即备份</button>
<button type="button" class="btn-secondary" id="hub-backup-refresh">刷新</button>
<span class="muted" id="hub-backup-status" style="font-size:.8rem"></span>
</div>
</div>
<div class="table-wrap">
<table class="backup-table">
<thead><tr><th>文件</th><th>时间</th><th>大小</th><th>操作</th></tr></thead>
<tbody id="hub-backup-body"><tr><td colspan="4" class="muted">加载中…</td></tr></tbody>
</table>
</div>
</div>
<div class="backup-block">
<div class="backup-block-head">
<h3>客户端备份</h3>
<p class="muted field-hint">经 Bridge 拉取各机备份列表,可下载到本地</p>
<div class="settings-actions">
<label class="settings-field settings-field--inline">
客户端
<select id="client-backup-instance"></select>
</label>
<button type="button" class="btn-secondary" id="client-backup-refresh">刷新</button>
<span class="muted" id="client-backup-status" style="font-size:.8rem"></span>
</div>
</div>
<div class="table-wrap">
<table class="backup-table">
<thead><tr><th>文件</th><th>时间</th><th>大小</th><th>操作</th></tr></thead>
<tbody id="client-backup-body"><tr><td colspan="4" class="muted">请选择客户端</td></tr></tbody>
</table>
</div>
</div>
</div>
<div class="table-wrap">
<table class="backup-table">
<thead><tr><th>文件</th><th>时间</th><th>大小</th><th>操作</th></tr></thead>
<tbody id="client-backup-body"><tr><td colspan="4" class="muted">请选择客户端</td></tr></tbody>
</table>
</div>
</div>
</section>
</section>
</div>
</div>
{% endblock %}
{% block scripts %}
<script src="{{ url_for('static', filename='settings_backup.js') }}?v=1"></script>
<script src="{{ url_for('static', filename='settings_backup.js') }}?v=2"></script>
<script>HubSettingsBackup.boot();</script>
{% endblock %}