系统设置增加「系统更新」Tab:中控本机更新与客户端远程更新,实例页入口移除。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-04 07:24:36 +08:00
parent f2b29870ae
commit bce446178d
8 changed files with 497 additions and 199 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=10">
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=11">
</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') %}
+5 -12
View File
@@ -23,20 +23,12 @@
<p class="muted">暂无实例.先在 crypto_okx 配置 HUB_BRIDGE_TOKEN 并公网可访问.</p>
{% endif %}
{% for inst in instances %}
<details class="inst-row" data-id="{{ inst.id }}" data-name="{{ inst.name }}">
<details class="inst-row">
<summary>
<strong>{{ inst.name }}</strong>
<span class="muted">{{ inst.base_url }}</span>
{% if inst.enabled %}启用{% else %}停用{% endif %}
<span class="inst-version muted" data-inst-version>—</span>
</summary>
<div class="inst-remote-actions">
<button type="button" class="btn" data-inst-update {% if not inst.enabled %}disabled title="实例未启用"{% endif %}>远程更新</button>
<button type="button" class="btn btn-secondary btn-sm" data-inst-refresh-ver>刷新版本</button>
<a class="btn" href="/desk?id={{ inst.id }}">内嵌打开</a>
<span class="inst-update-status muted" data-inst-update-status></span>
</div>
<p class="muted inst-update-hint">远程更新 = 客户端 git pull + pm2 restart;有持仓时慎用。</p>
<form method="post" class="form-grid">
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" value="{{ inst.id }}">
@@ -53,10 +45,11 @@
<input type="hidden" name="id" value="{{ inst.id }}">
<button type="submit" class="btn-danger">删除</button>
</form>
<p>
<a class="btn" href="/desk?id={{ inst.id }}">内嵌打开</a>
<a class="btn btn-secondary" href="/settings?tab=update">系统更新</a>
</p>
</details>
{% endfor %}
</section>
{% endblock %}
{% block scripts %}
<script src="{{ url_for('static', filename='instances.js') }}?v=1"></script>
{% endblock %}
+47 -3
View File
@@ -2,12 +2,12 @@
{% 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 %}
{% if _tab not in ('account', 'wechat', 'backup', 'update') %}{% 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>
@@ -15,11 +15,13 @@
<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 %}>
<input type="radio" name="hub-settings-tab" id="hub-set-update" class="settings-tab-radio"{% if _tab == 'update' %} checked{% endif %}>
<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>
<label for="hub-set-update" class="settings-tab-btn" role="tab">系统更新</label>
</div>
<div class="settings-panels">
@@ -138,10 +140,52 @@
</div>
</div>
</section>
<section class="settings-panel settings-panel--update" role="tabpanel">
<div class="settings-card-head">
<span class="settings-badge">Update</span>
<h2>系统更新</h2>
<p class="muted">快速更新 = git pull + pm2 restart。中控本机更新;客户端经 Bridge 远程下发。有持仓时慎用。</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-update-version" class="update-version">—</code></p>
<div class="settings-actions">
<button type="button" class="settings-primary" id="hub-update-btn">更新中控</button>
<button type="button" class="btn-secondary" id="hub-update-refresh">刷新版本</button>
<span class="update-status muted" id="hub-update-status"></span>
</div>
</div>
</div>
<div class="backup-block">
<div class="backup-block-head">
<h3>客户端远程更新</h3>
<p class="muted field-hint">经 Bridge 探测版本并下发更新;客户端需已具备 <code>/api/hub/update</code></p>
<div class="settings-actions">
<button type="button" class="btn-secondary" id="client-update-refresh">刷新列表</button>
</div>
</div>
<div class="table-wrap">
<table class="backup-table update-table">
<thead><tr><th>实例</th><th>版本</th><th>状态</th><th>操作</th></tr></thead>
<tbody id="client-update-body"><tr><td colspan="4" class="muted">加载中…</td></tr></tbody>
</table>
</div>
</div>
</div>
</section>
</div>
</div>
{% endblock %}
{% block scripts %}
<script src="{{ url_for('static', filename='settings_backup.js') }}?v=2"></script>
<script>HubSettingsBackup.boot();</script>
<script src="{{ url_for('static', filename='settings_update.js') }}?v=1"></script>
<script>
HubSettingsBackup.boot();
HubSettingsUpdate.boot();
</script>
{% endblock %}