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

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) {
const exit = orderExitText(o);
const meta = [];
@@ -176,6 +187,9 @@
escapeHtml(orderTriggerText(o)) +
"</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>" : "") +
(actions ? '<div class="hub-phone-cond-actions">' + actions + "</div>" : "") +
"</article>"
@@ -274,67 +288,90 @@
renderCandidateGroup("", other, checkedIds);
}
async function loadOrders() {
const box = document.getElementById("cond-list");
function renderDesktopRows(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;
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 d = await r.json();
const list = d.orders || [];
if (!list.length) {
box.innerHTML = '<div class="cond-empty">暂无条件单</div>';
return;
}
if (isHubPhone()) {
box.innerHTML =
'<div class="hub-phone-cond-list">' +
list.map(renderPhoneOrderCard).join("") +
"</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);
const active = [];
const done = [];
list.forEach(function (o) {
if (isActiveOrder(o)) active.push(o);
else done.push(o);
});
fillOrderBox(activeBox, active, "暂无进行中的条件单");
fillOrderBox(doneBox, done, "暂无已结束的条件单");
}
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>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>{% block title %}加密货币|OKX 期权中控{% endblock %}</title>
<meta name="theme-color" content="#070b14">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<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="apple-touch-icon" href="{{ url_for('static', filename='icons/apple-touch-icon.png') }}?v=2">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=43">
<script>
(function () {
try {
if (window.matchMedia("(max-width: 720px)").matches) {
document.documentElement.classList.add("hub-phone-html");
}
} catch (e) {}
})();
</script>
</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 %}">
{% if session.get('logged_in') %}
<a href="/logout" class="topbar-logout hub-desk-chrome">退出</a>
{% endif %}
<main class="main">
{% if session.get('logged_in') %}
<header class="hub-phone-bar hub-phone-chrome">
<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="nav-spot-row" data-base="ETH">
<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-pct" data-field="change_pct">—</span>
</div>
<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-last" data-field="last">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span>
</div>
</div>
</header>
<a href="/" class="topbar-brand hub-desk-chrome">加密货币|OKX 期权中控</a>
<div class="topbar-row hub-desk-chrome">
<nav class="topbar-nav">
<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="/instances" class="{% if request.path.startswith('/instances') %}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="/settings" class="{% if request.path.startswith('/settings') %}active{% endif %}">系统设置</a>
</nav>
<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">
<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-sym">ETHUSDT</span>
<span class="nav-spot-last" data-field="last">—</span>
<span class="nav-spot-chg" data-field="change">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span>
</div>
<div class="nav-spot-row" data-base="BTC">
<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-sym">BTCUSDT</span>
<span class="nav-spot-last" data-field="last">—</span>
<span class="nav-spot-chg" data-field="change">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span>
</div>
</div>
</div>
{% endif %}
{% with messages = get_flashed_messages() %}
{% if messages %}<div class="flash">{{ messages[0] }}</div>{% endif %}
{% endwith %}
{% block body %}{% endblock %}
</main>
{% if session.get('logged_in') %}
<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="/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>
</nav>
<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-sheet" role="dialog" aria-modal="true">
<div class="hub-phone-more-handle" aria-hidden="true"></div>
<h2 class="hub-phone-more-title">更多</h2>
<p class="hub-phone-more-hint">次要页面 · 完整操作请用电脑</p>
<nav class="hub-phone-more-nav">
<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="/settings"{% if request.path.startswith('/settings') %} class="is-active"{% endif %}>系统设置</a>
<a href="/logout">退出登录</a>
</nav>
<button type="button" class="hub-phone-more-close" id="hub-phone-more-close">关闭</button>
</div>
</div>
{% endif %}
{% if session.get('logged_in') and not request.path.startswith('/desk') %}
<script src="{{ url_for('static', filename='hub_quotes.js') }}?v=2"></script>
{% endif %}
{% block scripts %}{% endblock %}
{% if session.get('logged_in') and not request.path.startswith('/desk') %}
<script>if (window.HubQuotes) HubQuotes.boot();</script>
{% endif %}
<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>if (window.HubPwa) HubPwa.boot();</script>
<script>if (window.HubPhone) HubPhone.boot();</script>
</body>
</html>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>{% block title %}加密货币|OKX 期权中控{% endblock %}</title>
<meta name="theme-color" content="#070b14">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<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="apple-touch-icon" href="{{ url_for('static', filename='icons/apple-touch-icon.png') }}?v=2">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=44">
<script>
(function () {
try {
if (window.matchMedia("(max-width: 720px)").matches) {
document.documentElement.classList.add("hub-phone-html");
}
} catch (e) {}
})();
</script>
</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 %}">
{% if session.get('logged_in') %}
<a href="/logout" class="topbar-logout hub-desk-chrome">退出</a>
{% endif %}
<main class="main">
{% if session.get('logged_in') %}
<header class="hub-phone-bar hub-phone-chrome">
<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="nav-spot-row" data-base="ETH">
<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-pct" data-field="change_pct">—</span>
</div>
<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-last" data-field="last">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span>
</div>
</div>
</header>
<a href="/" class="topbar-brand hub-desk-chrome">加密货币|OKX 期权中控</a>
<div class="topbar-row hub-desk-chrome">
<nav class="topbar-nav">
<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="/instances" class="{% if request.path.startswith('/instances') %}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="/settings" class="{% if request.path.startswith('/settings') %}active{% endif %}">系统设置</a>
</nav>
<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">
<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-sym">ETHUSDT</span>
<span class="nav-spot-last" data-field="last">—</span>
<span class="nav-spot-chg" data-field="change">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span>
</div>
<div class="nav-spot-row" data-base="BTC">
<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-sym">BTCUSDT</span>
<span class="nav-spot-last" data-field="last">—</span>
<span class="nav-spot-chg" data-field="change">—</span>
<span class="nav-spot-pct" data-field="change_pct">—</span>
</div>
</div>
</div>
{% endif %}
{% with messages = get_flashed_messages() %}
{% if messages %}<div class="flash">{{ messages[0] }}</div>{% endif %}
{% endwith %}
{% block body %}{% endblock %}
</main>
{% if session.get('logged_in') %}
<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="/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>
</nav>
<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-sheet" role="dialog" aria-modal="true">
<div class="hub-phone-more-handle" aria-hidden="true"></div>
<h2 class="hub-phone-more-title">更多</h2>
<p class="hub-phone-more-hint">次要页面 · 完整操作请用电脑</p>
<nav class="hub-phone-more-nav">
<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="/settings"{% if request.path.startswith('/settings') %} class="is-active"{% endif %}>系统设置</a>
<a href="/logout">退出登录</a>
</nav>
<button type="button" class="hub-phone-more-close" id="hub-phone-more-close">关闭</button>
</div>
</div>
{% endif %}
{% if session.get('logged_in') and not request.path.startswith('/desk') %}
<script src="{{ url_for('static', filename='hub_quotes.js') }}?v=2"></script>
{% endif %}
{% block scripts %}{% endblock %}
{% if session.get('logged_in') and not request.path.startswith('/desk') %}
<script>if (window.HubQuotes) HubQuotes.boot();</script>
{% endif %}
<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>if (window.HubPwa) HubPwa.boot();</script>
<script>if (window.HubPhone) HubPhone.boot();</script>
</body>
</html>
+10 -3
View File
@@ -79,13 +79,20 @@
<section class="panel cond-card">
<div class="cond-card-head">
<h2>条件单历史</h2>
<h2>进行中</h2>
</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>
</div>
{% endblock %}
{% 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>
{% endblock %}