条件单拆成进行中与已结束两表,并展示开仓时间。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-06 16:20:33 +08:00
parent da1bae8751
commit 4ecabd414c
4 changed files with 2314 additions and 2265 deletions
+94 -57
View File
@@ -152,6 +152,17 @@
}); });
} }
function isActiveOrder(o) {
const st = String((o && o.status) || "");
return st === "armed" || st === "triggering" || st === "open";
}
function formatOpenTime(o) {
const raw = String((o && o.opened_at) || "").trim();
if (!raw) return "—";
return raw.replace("T", " ").slice(0, 19);
}
function renderPhoneOrderCard(o) { function renderPhoneOrderCard(o) {
const exit = orderExitText(o); const exit = orderExitText(o);
const meta = []; const meta = [];
@@ -176,6 +187,9 @@
escapeHtml(orderTriggerText(o)) + escapeHtml(orderTriggerText(o)) +
"</div>" + "</div>" +
(meta.length ? '<div class="hub-phone-cond-meta muted">' + escapeHtml(meta.join(" · ")) + "</div>" : "") + (meta.length ? '<div class="hub-phone-cond-meta muted">' + escapeHtml(meta.join(" · ")) + "</div>" : "") +
'<div class="hub-phone-cond-meta muted">开仓 ' +
escapeHtml(formatOpenTime(o)) +
"</div>" +
(o.message ? '<div class="hub-phone-cond-msg muted">' + escapeHtml(o.message) + "</div>" : "") + (o.message ? '<div class="hub-phone-cond-msg muted">' + escapeHtml(o.message) + "</div>" : "") +
(actions ? '<div class="hub-phone-cond-actions">' + actions + "</div>" : "") + (actions ? '<div class="hub-phone-cond-actions">' + actions + "</div>" : "") +
"</article>" "</article>"
@@ -274,67 +288,90 @@
renderCandidateGroup("", other, checkedIds); renderCandidateGroup("", other, checkedIds);
} }
async function loadOrders() { function renderDesktopRows(list) {
const box = document.getElementById("cond-list"); return list
.map(function (o) {
return (
"<tr>" +
"<td>" +
escapeHtml(o.instance_name || "") +
"</td>" +
'<td><span class="cond-st ' +
statusClass(o) +
'">' +
escapeHtml(statusLabel(o)) +
"</span></td>" +
"<td>" +
escapeHtml((o.underlying || "") + " " + (o.opt_type || "")) +
"</td>" +
"<td>" +
escapeHtml(orderTriggerText(o).replace("≤", " ≤ ").replace("≥", " ≥ ")) +
"</td>" +
"<td>" +
escapeHtml(o.deviation_pct != null ? o.deviation_pct + "%" : "—") +
"</td>" +
"<td>" +
escapeHtml(o.min_expiry_hours != null ? String(o.min_expiry_hours) : "—") +
"</td>" +
"<td>" +
escapeHtml(orderExitText(o) || "—") +
"</td>" +
'<td class="cond-td-time">' +
escapeHtml(formatOpenTime(o)) +
"</td>" +
'<td class="muted">' +
escapeHtml(o.message || "") +
"</td>" +
'<td><div class="overview-actions">' +
orderActionHtml(o) +
"</div></td>" +
"</tr>"
);
})
.join("");
}
function renderDesktopTable(list, emptyText) {
if (!list.length) {
return '<div class="cond-empty">' + escapeHtml(emptyText) + "</div>";
}
return (
'<div class="overview-table-wrap cond-table-wrap"><table class="overview-table"><thead><tr>' +
"<th>客户端</th><th>状态</th><th>标的</th><th>触发</th><th>偏离</th><th>到期h</th><th>出场</th><th>开仓时间</th><th>说明</th><th>操作</th>" +
"</tr></thead><tbody>" +
renderDesktopRows(list) +
"</tbody></table></div>"
);
}
function renderPhoneList(list, emptyText) {
if (!list.length) {
return '<div class="cond-empty">' + escapeHtml(emptyText) + "</div>";
}
return '<div class="hub-phone-cond-list">' + list.map(renderPhoneOrderCard).join("") + "</div>";
}
function fillOrderBox(box, list, emptyText) {
if (!box) return; if (!box) return;
box.innerHTML = isHubPhone() ? renderPhoneList(list, emptyText) : renderDesktopTable(list, emptyText);
bindOrderActions(box);
}
async function loadOrders() {
const activeBox = document.getElementById("cond-list-active");
const doneBox = document.getElementById("cond-list-done");
if (!activeBox && !doneBox) return;
const r = await fetch("/api/cond_orders"); const r = await fetch("/api/cond_orders");
const d = await r.json(); const d = await r.json();
const list = d.orders || []; const list = d.orders || [];
if (!list.length) { const active = [];
box.innerHTML = '<div class="cond-empty">暂无条件单</div>'; const done = [];
return; list.forEach(function (o) {
} if (isActiveOrder(o)) active.push(o);
if (isHubPhone()) { else done.push(o);
box.innerHTML = });
'<div class="hub-phone-cond-list">' + fillOrderBox(activeBox, active, "暂无进行中的条件单");
list.map(renderPhoneOrderCard).join("") + fillOrderBox(doneBox, done, "暂无已结束的条件单");
"</div>";
bindOrderActions(box);
return;
}
box.innerHTML =
'<div class="overview-table-wrap cond-table-wrap"><table class="overview-table"><thead><tr>' +
"<th>客户端</th><th>状态</th><th>标的</th><th>触发</th><th>偏离</th><th>到期h</th><th>出场</th><th>说明</th><th>操作</th>" +
"</tr></thead><tbody>" +
list
.map(function (o) {
return (
"<tr>" +
"<td>" +
escapeHtml(o.instance_name || "") +
"</td>" +
'<td><span class="cond-st ' +
statusClass(o) +
'">' +
escapeHtml(statusLabel(o)) +
"</span></td>" +
"<td>" +
escapeHtml((o.underlying || "") + " " + (o.opt_type || "")) +
"</td>" +
"<td>" +
escapeHtml(orderTriggerText(o).replace("≤", " ≤ ").replace("≥", " ≥ ")) +
"</td>" +
"<td>" +
escapeHtml(o.deviation_pct != null ? o.deviation_pct + "%" : "—") +
"</td>" +
"<td>" +
escapeHtml(o.min_expiry_hours != null ? String(o.min_expiry_hours) : "—") +
"</td>" +
"<td>" +
escapeHtml(orderExitText(o) || "—") +
"</td>" +
'<td class="muted">' +
escapeHtml(o.message || "") +
"</td>" +
'<td><div class="overview-actions">' +
orderActionHtml(o) +
"</div></td>" +
"</tr>"
);
})
.join("") +
"</tbody></table></div>";
bindOrderActions(box);
} }
async function createOrder() { async function createOrder() {
+2095 -2090
View File
File diff suppressed because it is too large Load Diff
+115 -115
View File
@@ -1,115 +1,115 @@
<!doctype html> <!doctype html>
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>{% block title %}加密货币|OKX 期权中控{% endblock %}</title> <title>{% block title %}加密货币|OKX 期权中控{% endblock %}</title>
<meta name="theme-color" content="#070b14"> <meta name="theme-color" content="#070b14">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="期权中控"> <meta name="apple-mobile-web-app-title" content="期权中控">
<link rel="icon" href="{{ url_for('static', filename='icons/favicon.ico') }}?v=2" sizes="any"> <link rel="icon" href="{{ url_for('static', filename='icons/favicon.ico') }}?v=2" sizes="any">
<link rel="apple-touch-icon" href="{{ url_for('static', filename='icons/apple-touch-icon.png') }}?v=2"> <link rel="apple-touch-icon" href="{{ url_for('static', filename='icons/apple-touch-icon.png') }}?v=2">
<link rel="manifest" href="/manifest.webmanifest"> <link rel="manifest" href="/manifest.webmanifest">
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=43"> <link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=44">
<script> <script>
(function () { (function () {
try { try {
if (window.matchMedia("(max-width: 720px)").matches) { if (window.matchMedia("(max-width: 720px)").matches) {
document.documentElement.classList.add("hub-phone-html"); document.documentElement.classList.add("hub-phone-html");
} }
} catch (e) {} } catch (e) {}
})(); })();
</script> </script>
</head> </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.startswith('/instances') %}page-instances{% elif request.path.startswith('/settings') %}page-settings{% elif request.path.startswith('/cond_orders') %}page-cond-orders{% elif request.path == '/' %}page-dashboard{% endif %}"> <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.startswith('/instances') %}page-instances{% elif request.path.startswith('/settings') %}page-settings{% elif request.path.startswith('/cond_orders') %}page-cond-orders{% elif request.path == '/' %}page-dashboard{% endif %}">
{% if session.get('logged_in') %} {% if session.get('logged_in') %}
<a href="/logout" class="topbar-logout hub-desk-chrome">退出</a> <a href="/logout" class="topbar-logout hub-desk-chrome">退出</a>
{% endif %} {% endif %}
<main class="main"> <main class="main">
{% if session.get('logged_in') %} {% if session.get('logged_in') %}
<header class="hub-phone-bar hub-phone-chrome"> <header class="hub-phone-bar hub-phone-chrome">
<div class="hub-phone-bar-title">期权中控</div> <div class="hub-phone-bar-title">期权中控</div>
<div class="hub-phone-quotes" id="nav-spot-tickers-phone" data-hub-quotes="1" aria-label="BTC ETH 报价"> <div class="hub-phone-quotes" id="nav-spot-tickers-phone" data-hub-quotes="1" aria-label="BTC ETH 报价">
<div class="nav-spot-row" data-base="ETH"> <div class="nav-spot-row" data-base="ETH">
<span class="nav-spot-icon nav-spot-icon--eth" aria-hidden="true">Ξ</span> <span class="nav-spot-icon nav-spot-icon--eth" aria-hidden="true">Ξ</span>
<span class="nav-spot-last" data-field="last">—</span> <span class="nav-spot-last" data-field="last">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span> <span class="nav-spot-pct" data-field="change_pct">—</span>
</div> </div>
<div class="nav-spot-row" data-base="BTC"> <div class="nav-spot-row" data-base="BTC">
<span class="nav-spot-icon nav-spot-icon--btc" aria-hidden="true">₿</span> <span class="nav-spot-icon nav-spot-icon--btc" aria-hidden="true">₿</span>
<span class="nav-spot-last" data-field="last">—</span> <span class="nav-spot-last" data-field="last">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span> <span class="nav-spot-pct" data-field="change_pct">—</span>
</div> </div>
</div> </div>
</header> </header>
<a href="/" class="topbar-brand hub-desk-chrome">加密货币|OKX 期权中控</a> <a href="/" class="topbar-brand hub-desk-chrome">加密货币|OKX 期权中控</a>
<div class="topbar-row hub-desk-chrome"> <div class="topbar-row hub-desk-chrome">
<nav class="topbar-nav"> <nav class="topbar-nav">
<a href="/" class="{% if request.path == '/' %}active{% endif %}">总览</a> <a href="/" class="{% if request.path == '/' %}active{% endif %}">总览</a>
<a href="/cond_orders" class="{% if request.path.startswith('/cond_orders') %}active{% endif %}">条件单</a> <a href="/cond_orders" class="{% if request.path.startswith('/cond_orders') %}active{% endif %}">条件单</a>
<a href="/instances" class="{% if request.path.startswith('/instances') %}active{% endif %}">实例</a> <a href="/instances" class="{% if request.path.startswith('/instances') %}active{% endif %}">实例</a>
<a href="/desk" class="{% if request.path.startswith('/desk') %}active{% endif %}">工作台</a> <a href="/desk" class="{% if request.path.startswith('/desk') %}active{% endif %}">工作台</a>
<a href="/stats" class="{% if request.path.startswith('/stats') %}active{% endif %}">数据统计</a> <a href="/stats" class="{% if request.path.startswith('/stats') %}active{% endif %}">数据统计</a>
<a href="/settings" class="{% if request.path.startswith('/settings') %}active{% endif %}">系统设置</a> <a href="/settings" class="{% if request.path.startswith('/settings') %}active{% endif %}">系统设置</a>
</nav> </nav>
<div class="top-nav-spot-tickers" id="nav-spot-tickers" data-hub-quotes="1" aria-label="BTC ETH 报价" title="来自在线客户端 · 相对北京 08:00"> <div class="top-nav-spot-tickers" id="nav-spot-tickers" data-hub-quotes="1" aria-label="BTC ETH 报价" title="来自在线客户端 · 相对北京 08:00">
<div class="nav-spot-row" data-base="ETH"> <div class="nav-spot-row" data-base="ETH">
<span class="nav-spot-ribbon" aria-hidden="true"></span> <span class="nav-spot-ribbon" aria-hidden="true"></span>
<span class="nav-spot-icon nav-spot-icon--eth" aria-hidden="true">Ξ</span> <span class="nav-spot-icon nav-spot-icon--eth" aria-hidden="true">Ξ</span>
<span class="nav-spot-sym">ETHUSDT</span> <span class="nav-spot-sym">ETHUSDT</span>
<span class="nav-spot-last" data-field="last">—</span> <span class="nav-spot-last" data-field="last">—</span>
<span class="nav-spot-chg" data-field="change">—</span> <span class="nav-spot-chg" data-field="change">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span> <span class="nav-spot-pct" data-field="change_pct">—</span>
</div> </div>
<div class="nav-spot-row" data-base="BTC"> <div class="nav-spot-row" data-base="BTC">
<span class="nav-spot-ribbon" aria-hidden="true"></span> <span class="nav-spot-ribbon" aria-hidden="true"></span>
<span class="nav-spot-icon nav-spot-icon--btc" aria-hidden="true">₿</span> <span class="nav-spot-icon nav-spot-icon--btc" aria-hidden="true">₿</span>
<span class="nav-spot-sym">BTCUSDT</span> <span class="nav-spot-sym">BTCUSDT</span>
<span class="nav-spot-last" data-field="last">—</span> <span class="nav-spot-last" data-field="last">—</span>
<span class="nav-spot-chg" data-field="change">—</span> <span class="nav-spot-chg" data-field="change">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span> <span class="nav-spot-pct" data-field="change_pct">—</span>
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% with messages = get_flashed_messages() %} {% with messages = get_flashed_messages() %}
{% if messages %}<div class="flash">{{ messages[0] }}</div>{% endif %} {% if messages %}<div class="flash">{{ messages[0] }}</div>{% endif %}
{% endwith %} {% endwith %}
{% block body %}{% endblock %} {% block body %}{% endblock %}
</main> </main>
{% if session.get('logged_in') %} {% if session.get('logged_in') %}
<nav id="hub-phone-tabbar" class="hub-phone-tabbar hub-phone-chrome" aria-label="手机导航"> <nav id="hub-phone-tabbar" class="hub-phone-tabbar hub-phone-chrome" aria-label="手机导航">
<a href="/" class="hub-phone-tab{% if request.path == '/' %} is-active{% endif %}" data-hub-tab="/">总览</a> <a href="/" class="hub-phone-tab{% if request.path == '/' %} is-active{% endif %}" data-hub-tab="/">总览</a>
<a href="/cond_orders" class="hub-phone-tab{% if request.path.startswith('/cond_orders') %} is-active{% endif %}" data-hub-tab="/cond_orders">条件单</a> <a href="/cond_orders" class="hub-phone-tab{% if request.path.startswith('/cond_orders') %} is-active{% endif %}" data-hub-tab="/cond_orders">条件单</a>
<button type="button" class="hub-phone-tab" id="hub-phone-more-btn" aria-haspopup="dialog" aria-expanded="false">更多</button> <button type="button" class="hub-phone-tab" id="hub-phone-more-btn" aria-haspopup="dialog" aria-expanded="false">更多</button>
</nav> </nav>
<div id="hub-phone-more" class="hub-phone-more hub-phone-chrome" aria-hidden="true"> <div id="hub-phone-more" class="hub-phone-more hub-phone-chrome" aria-hidden="true">
<div class="hub-phone-more-backdrop" id="hub-phone-more-backdrop"></div> <div class="hub-phone-more-backdrop" id="hub-phone-more-backdrop"></div>
<div class="hub-phone-more-sheet" role="dialog" aria-modal="true"> <div class="hub-phone-more-sheet" role="dialog" aria-modal="true">
<div class="hub-phone-more-handle" aria-hidden="true"></div> <div class="hub-phone-more-handle" aria-hidden="true"></div>
<h2 class="hub-phone-more-title">更多</h2> <h2 class="hub-phone-more-title">更多</h2>
<p class="hub-phone-more-hint">次要页面 · 完整操作请用电脑</p> <p class="hub-phone-more-hint">次要页面 · 完整操作请用电脑</p>
<nav class="hub-phone-more-nav"> <nav class="hub-phone-more-nav">
<a href="/instances"{% if request.path.startswith('/instances') %} class="is-active"{% endif %}>实例</a> <a href="/instances"{% if request.path.startswith('/instances') %} class="is-active"{% endif %}>实例</a>
<a href="/stats"{% if request.path.startswith('/stats') %} class="is-active"{% endif %}>数据统计</a> <a href="/stats"{% if request.path.startswith('/stats') %} class="is-active"{% endif %}>数据统计</a>
<a href="/settings"{% if request.path.startswith('/settings') %} class="is-active"{% endif %}>系统设置</a> <a href="/settings"{% if request.path.startswith('/settings') %} class="is-active"{% endif %}>系统设置</a>
<a href="/logout">退出登录</a> <a href="/logout">退出登录</a>
</nav> </nav>
<button type="button" class="hub-phone-more-close" id="hub-phone-more-close">关闭</button> <button type="button" class="hub-phone-more-close" id="hub-phone-more-close">关闭</button>
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% if session.get('logged_in') and not request.path.startswith('/desk') %} {% if session.get('logged_in') and not request.path.startswith('/desk') %}
<script src="{{ url_for('static', filename='hub_quotes.js') }}?v=2"></script> <script src="{{ url_for('static', filename='hub_quotes.js') }}?v=2"></script>
{% endif %} {% endif %}
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
{% if session.get('logged_in') and not request.path.startswith('/desk') %} {% if session.get('logged_in') and not request.path.startswith('/desk') %}
<script>if (window.HubQuotes) HubQuotes.boot();</script> <script>if (window.HubQuotes) HubQuotes.boot();</script>
{% endif %} {% endif %}
<script src="{{ url_for('static', filename='hub_pwa.js') }}?v=2"></script> <script src="{{ url_for('static', filename='hub_pwa.js') }}?v=2"></script>
<script src="{{ url_for('static', filename='hub_phone.js') }}?v=1"></script> <script src="{{ url_for('static', filename='hub_phone.js') }}?v=1"></script>
<script>if (window.HubPwa) HubPwa.boot();</script> <script>if (window.HubPwa) HubPwa.boot();</script>
<script>if (window.HubPhone) HubPhone.boot();</script> <script>if (window.HubPhone) HubPhone.boot();</script>
</body> </body>
</html> </html>
+10 -3
View File
@@ -79,13 +79,20 @@
<section class="panel cond-card"> <section class="panel cond-card">
<div class="cond-card-head"> <div class="cond-card-head">
<h2>条件单历史</h2> <h2>进行中</h2>
</div> </div>
<div id="cond-list" class="muted">加载中…</div> <div id="cond-list-active" class="muted">加载中…</div>
</section>
<section class="panel cond-card">
<div class="cond-card-head">
<h2>已结束</h2>
</div>
<div id="cond-list-done" class="muted">加载中…</div>
</section> </section>
</div> </div>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ url_for('static', filename='cond_orders.js') }}?v=3"></script> <script src="{{ url_for('static', filename='cond_orders.js') }}?v=4"></script>
<script>HubCondOrders.boot();</script> <script>HubCondOrders.boot();</script>
{% endblock %} {% endblock %}