Add responsive mobile layout, records cards, and tablet settings fold fix.

Mobile gets compact trade/records UI with detail modals; static assets are cache-busted and settings cards fold correctly on tablet grid layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-29 16:42:38 +08:00
parent 44bec23296
commit c5262a0a54
14 changed files with 1465 additions and 35 deletions
+48 -4
View File
@@ -218,11 +218,45 @@ def require_nav(key: str):
return decorator return decorator
def _static_asset_v() -> str:
base = os.path.dirname(os.path.abspath(__file__))
rels = (
"static/js/trade.js",
"static/js/orientation.js",
"static/css/records.css",
"static/js/records.js",
"static/js/settings.js",
"static/css/mobile.css",
"static/css/responsive.css",
"static/css/trade.css",
"static/css/base.css",
)
mtimes = []
for rel in rels:
path = os.path.join(base, rel.replace("/", os.sep))
if os.path.isfile(path):
mtimes.append(os.path.getmtime(path))
return str(int(max(mtimes))) if mtimes else "0"
def _ua_is_phone(ua: str) -> bool:
ua_l = (ua or "").lower()
if "ipad" in ua_l:
return False
if "android" in ua_l and "mobile" not in ua_l:
return False
if any(x in ua_l for x in ("iphone", "ipod", "windows phone", "iemobile")):
return True
if "android" in ua_l and "mobile" in ua_l:
return True
if "mobile" in ua_l or "harmonyos" in ua_l or "openharmony" in ua_l:
return True
return False
@app.context_processor @app.context_processor
def inject_globals(): def inject_globals():
trade_js = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static", "js", "trade.js") return {"nav_items": get_nav_items(get_setting), "asset_v": _static_asset_v()}
asset_v = str(int(os.path.getmtime(trade_js))) if os.path.isfile(trade_js) else "0"
return {"nav_items": get_nav_items(get_setting), "asset_v": asset_v}
def _trading_mode() -> str: def _trading_mode() -> str:
@@ -755,8 +789,18 @@ def index():
@app.route("/manifest.webmanifest") @app.route("/manifest.webmanifest")
def web_manifest(): def web_manifest():
response = app.send_static_file("manifest.json") import json
manifest_path = os.path.join(app.static_folder, "manifest.json")
with open(manifest_path, encoding="utf-8") as fh:
data = json.load(fh)
if _ua_is_phone(request.headers.get("User-Agent", "")):
data["orientation"] = "portrait-primary"
else:
data["orientation"] = "any"
response = app.make_response(json.dumps(data, ensure_ascii=False))
response.mimetype = "application/manifest+json" response.mimetype = "application/manifest+json"
response.headers["Cache-Control"] = "no-cache"
return response return response
+34
View File
@@ -0,0 +1,34 @@
"""Deploy responsive / orientation layout fixes."""
import paramiko
import sys
from pathlib import Path
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
root = Path(__file__).resolve().parents[1]
files = [
"app.py",
"static/css/trade.css",
"static/css/mobile.css",
"static/css/responsive.css",
"static/css/records.css",
"static/js/orientation.js",
"static/js/nav.js",
"static/js/records.js",
"static/js/settings.js",
"templates/base.html",
"templates/trade.html",
"templates/strategy.html",
"templates/records.html",
"templates/settings.html",
]
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("192.168.8.21", username="root", password="woaini88", timeout=15)
sftp = c.open_sftp()
for rel in files:
sftp.put(str(root / rel), f"/opt/qihuo/{rel.replace(chr(92), '/')}")
print("uploaded", rel)
sftp.close()
_, o, _ = c.exec_command("cd /opt/qihuo && pm2 restart qihuo")
print(o.read().decode("utf-8", errors="replace"))
c.close()
+553
View File
@@ -0,0 +1,553 @@
/* Copyright (c) 2025-2026 马建军. All rights reserved.
* 手机端竖屏 UI
*/
html:is([data-mobile="1"], .layout-phone) {
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
overflow-x: hidden;
width: 100%;
max-width: 100vw;
}
html:is([data-mobile="1"], .layout-phone) body {
font-size: 15px;
overflow-x: hidden;
overflow-y: auto;
width: 100%;
max-width: 100vw;
-webkit-overflow-scrolling: touch;
}
html:is([data-mobile="1"], .layout-phone) .page-wrap {
max-width: 100%;
width: 100%;
overflow-x: hidden;
}
html:is([data-mobile="1"], .layout-phone) .tech-bg .tech-scanline {
display: none;
}
/* ── 顶栏:菜单 | 标题 | 主题 ── */
html:is([data-mobile="1"], .layout-phone) .site-header {
display: grid;
grid-template-columns: 40px minmax(0, 1fr) auto;
grid-template-areas: "toggle title tools";
align-items: center;
column-gap: .45rem;
padding: calc(var(--safe-top) + .4rem) .6rem .5rem;
text-align: left;
border-bottom: 1px solid var(--border-header);
position: sticky;
top: 0;
z-index: 80;
background: var(--card-bg);
backdrop-filter: blur(10px);
width: 100%;
max-width: 100%;
box-sizing: border-box;
}
html:is([data-mobile="1"], .layout-phone) .header-bar {
display: contents;
}
html:is([data-mobile="1"], .layout-phone) .nav-toggle {
display: inline-flex !important;
grid-area: toggle;
width: 40px;
height: 40px;
flex-shrink: 0;
}
html:is([data-mobile="1"], .layout-phone) .header-tools {
grid-area: tools;
display: inline-flex;
align-items: center;
justify-content: flex-end;
gap: .2rem;
flex-shrink: 0;
}
html:is([data-mobile="1"], .layout-phone) .header-tools .pwa-install-btn {
display: none;
}
html:is([data-mobile="1"], .layout-phone) .theme-switch {
padding: 2px;
border-radius: 999px;
}
html:is([data-mobile="1"], .layout-phone) .theme-switch-btn {
padding: .28rem .42rem;
font-size: .66rem;
min-height: 28px;
line-height: 1.1;
}
html:is([data-mobile="1"], .layout-phone) .user-bar {
display: none;
}
html:is([data-mobile="1"], .layout-phone) .site-title {
grid-area: title;
font-size: .9rem;
font-weight: 700;
margin: 0;
text-align: left;
line-height: 1.2;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
min-width: 0;
}
html:is([data-mobile="1"], .layout-phone) .site-title-mobile {
display: inline;
}
html:is([data-mobile="1"], .layout-phone) .site-title-desktop {
display: none;
}
.site-title-mobile {
display: none;
}
html:is([data-mobile="1"], .layout-phone) .site-title-sub {
display: none !important;
}
html:is([data-mobile="1"], .layout-phone) .pwa-ios-hint {
display: none !important;
}
html:is([data-mobile="1"], .layout-phone) .site-nav {
position: fixed !important;
top: 0;
left: 0;
width: min(88vw, 300px);
height: 100dvh;
margin: 0;
padding: calc(var(--safe-top) + 3.25rem) .85rem 1.25rem;
flex-direction: column !important;
flex-wrap: nowrap !important;
justify-content: flex-start !important;
align-items: stretch !important;
gap: .3rem;
background: var(--card-bg);
border-right: 1px solid var(--card-border);
box-shadow: var(--shadow-card-hover);
z-index: 100;
transform: translateX(-105%);
transition: transform .25s ease;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
html:is([data-mobile="1"], .layout-phone) .site-nav.open {
transform: translateX(0);
}
html:is([data-mobile="1"], .layout-phone) .site-nav a {
width: 100%;
text-align: left;
padding: .7rem .85rem;
font-size: .88rem;
min-height: 44px;
display: flex;
align-items: center;
border-radius: 10px;
white-space: nowrap;
}
html:is([data-mobile="1"], .layout-phone) .main {
padding: .65rem .6rem calc(1rem + var(--safe-bottom));
width: 100%;
max-width: 100%;
box-sizing: border-box;
}
html:is([data-mobile="1"], .layout-phone) .card {
padding: .85rem;
border-radius: 12px;
margin-bottom: .75rem;
overflow: visible;
max-width: 100%;
box-sizing: border-box;
}
html:is([data-mobile="1"], .layout-phone) .card h2 {
font-size: .95rem;
margin-bottom: .55rem;
}
html:is([data-mobile="1"], .layout-phone) .split-grid,
html:is([data-mobile="1"], .layout-phone) .trade-split,
html:is([data-mobile="1"], .layout-phone) .strategy-page .split-grid {
display: flex !important;
flex-direction: column !important;
gap: .75rem !important;
grid-template-columns: 1fr !important;
width: 100%;
max-width: 100%;
}
html:is([data-mobile="1"], .layout-phone) .split-grid .card,
html:is([data-mobile="1"], .layout-phone) .trade-split .card,
html:is([data-mobile="1"], .layout-phone) .strategy-page .split-grid .card {
min-height: auto !important;
height: auto !important;
width: 100%;
max-width: 100%;
}
/* ── 下单监控页 ── */
html:is([data-mobile="1"], .layout-phone) .trade-page {
width: 100%;
max-width: 100%;
overflow-x: hidden;
}
html:is([data-mobile="1"], .layout-phone) .trade-top-bar {
flex-direction: column;
gap: .55rem;
padding: .65rem;
border-radius: 12px;
background: var(--card-inner);
border: 1px solid var(--card-border);
margin-bottom: .75rem;
max-width: 100%;
box-sizing: border-box;
}
html:is([data-mobile="1"], .layout-phone) .trade-top-bar-main {
flex-direction: column;
align-items: flex-start;
gap: .35rem;
width: 100%;
min-width: 0;
}
html:is([data-mobile="1"], .layout-phone) .trade-top-bar-main .badge {
font-size: .68rem;
}
html:is([data-mobile="1"], .layout-phone) .trade-session-clock {
display: block;
font-size: .7rem;
line-height: 1.45;
word-break: break-word;
}
html:is([data-mobile="1"], .layout-phone) .trade-top-bar-actions {
width: 100%;
}
html:is([data-mobile="1"], .layout-phone) .trade-top-bar-actions .btn-ctp-sm {
width: 100%;
min-height: 44px;
}
html:is([data-mobile="1"], .layout-phone) .trade-top-hint {
font-size: .65rem;
line-height: 1.4;
white-space: normal;
}
html:is([data-mobile="1"], .layout-phone) .trade-form-rows {
width: 100%;
max-width: 100%;
min-width: 0;
}
html:is([data-mobile="1"], .layout-phone) .trade-form-line {
width: 100%;
max-width: 100%;
min-width: 0;
box-sizing: border-box;
}
/* 品种独占一行;方向 + 手数并排 */
html:is([data-mobile="1"], .layout-phone) .trade-form-line.line-3 {
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
gap: .45rem !important;
align-items: end;
}
html:is([data-mobile="1"], .layout-phone) .trade-form-line.line-3 .trade-field:first-child {
grid-column: 1 / -1 !important;
}
html:is([data-mobile="1"], .layout-phone) .trade-form-line.line-2 {
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
gap: .45rem !important;
}
html:is([data-mobile="1"], .layout-phone) .trade-field,
html:is([data-mobile="1"], .layout-phone) .symbol-wrap {
min-width: 0;
max-width: 100%;
}
html:is([data-mobile="1"], .layout-phone) .trade-field label,
html:is([data-mobile="1"], .layout-phone) .text-label {
font-size: .68rem;
margin-bottom: .18rem;
}
html:is([data-mobile="1"], .layout-phone) .trade-field input,
html:is([data-mobile="1"], .layout-phone) .trade-field select {
padding: .42rem .5rem;
max-width: 100%;
}
html:is([data-mobile="1"], .layout-phone) .symbol-input {
font-size: 14px;
}
html:is([data-mobile="1"], .layout-phone) .price-type-tabs {
margin-bottom: .22rem;
gap: .25rem;
}
html:is([data-mobile="1"], .layout-phone) .price-tab {
padding: .2rem .3rem;
font-size: .66rem;
flex: 1;
}
html:is([data-mobile="1"], .layout-phone) .form-compact .line-trend-head {
grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.7fr) minmax(0, 0.75fr) !important;
gap: .4rem .45rem !important;
}
html:is([data-mobile="1"], .layout-phone) .form-compact .line-2 {
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
gap: .4rem .45rem !important;
}
html:is([data-mobile="1"], .layout-phone) .form-compact .line-3 {
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
gap: .4rem .45rem !important;
}
html:is([data-mobile="1"], .layout-phone) #roll-form .form-line.line-2 {
grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr) !important;
gap: .4rem .45rem !important;
}
html:is([data-mobile="1"], .layout-phone) .form-compact .form-line {
min-width: 0;
}
html:is([data-mobile="1"], .layout-phone) .form-compact input,
html:is([data-mobile="1"], .layout-phone) .form-compact select {
padding: .42rem .5rem;
}
html:is([data-mobile="1"], .layout-phone) .trade-action-row {
flex-direction: column;
align-items: stretch;
}
html:is([data-mobile="1"], .layout-phone) .trade-action-row .btn-open {
width: 100%;
min-height: 44px;
}
html:is([data-mobile="1"], .layout-phone) .pos-metrics {
grid-template-columns: repeat(2, 1fr) !important;
gap: .45rem;
}
html:is([data-mobile="1"], .layout-phone) .pos-card {
padding: .75rem;
}
html:is([data-mobile="1"], .layout-phone) .pos-card-head {
flex-direction: column;
align-items: stretch;
gap: .45rem;
}
html:is([data-mobile="1"], .layout-phone) .pos-card-actions {
width: 100%;
justify-content: flex-end;
}
html:is([data-mobile="1"], .layout-phone) .rec-sort-bar {
flex-direction: column;
align-items: stretch;
gap: .45rem;
}
html:is([data-mobile="1"], .layout-phone) .rec-sort-bar select {
width: 100%;
min-width: 0;
}
html:is([data-mobile="1"], .layout-phone) #recommend .trade-table-wrap,
html:is([data-mobile="1"], .layout-phone) .trade-table-wrap {
overflow-x: auto !important;
overflow-y: auto;
max-height: 55vh;
-webkit-overflow-scrolling: touch;
width: 100%;
max-width: 100%;
}
html:is([data-mobile="1"], .layout-phone) .trade-table {
font-size: .72rem;
}
html:is([data-mobile="1"], .layout-phone) .strategy-page .split-grid .card {
min-height: auto !important;
}
html:is([data-mobile="1"], .layout-phone) .strategy-preview-table {
font-size: .66rem;
min-width: 0;
width: 100%;
}
html:is([data-mobile="1"], .layout-phone) .table-responsive {
margin-bottom: .5rem;
max-width: 100%;
overflow-x: auto;
}
html:is([data-mobile="1"], .layout-phone) .module-rules summary {
font-size: .78rem;
}
html:is([data-mobile="1"], .layout-phone) input,
html:is([data-mobile="1"], .layout-phone) select,
html:is([data-mobile="1"], .layout-phone) textarea,
html:is([data-mobile="1"], .layout-phone) button {
font-size: 16px;
}
html:is([data-mobile="1"], .layout-phone) .btn-primary {
min-height: 44px;
}
html:is([data-mobile="1"], .layout-phone) .site-nav::after {
content: attr(data-user-label);
display: block;
margin-top: auto;
padding: .85rem .5rem 0;
font-size: .72rem;
color: var(--text-muted);
border-top: 1px solid var(--table-border);
}
/* 桌面端:标题仍居中,工具栏绝对定位 */
html:not([data-mobile="1"]):not(.layout-phone) .header-bar {
display: block;
position: relative;
min-height: 2rem;
}
html:not([data-mobile="1"]):not(.layout-phone) .nav-toggle {
display: none;
}
html:not([data-mobile="1"]):not(.layout-phone) .site-title {
display: block;
text-align: center;
margin: 0 0 1.65rem;
font-size: 1.75rem;
width: 100%;
}
html:not([data-mobile="1"]):not(.layout-phone) .site-title-mobile {
display: none;
}
html:not([data-mobile="1"]):not(.layout-phone) .site-title-desktop {
display: inline;
}
html:not([data-mobile="1"]):not(.layout-phone) .header-tools {
position: absolute;
top: 0;
left: 0;
z-index: 20;
}
html:not([data-mobile="1"]):not(.layout-phone) .user-bar {
display: block;
position: absolute;
top: 0;
right: 0;
}
/* 触控小屏兜底(JS 未执行时) */
@media (pointer: coarse) and (max-width: 600px) {
body {
overflow-x: hidden;
overflow-y: auto;
max-width: 100vw;
}
.site-header {
display: grid !important;
grid-template-columns: 40px minmax(0, 1fr) auto !important;
grid-template-areas: "toggle title tools" !important;
align-items: center;
column-gap: .45rem;
padding: calc(var(--safe-top) + .4rem) .6rem .5rem;
text-align: left;
max-width: 100%;
}
.header-bar {
display: contents !important;
}
.nav-toggle {
display: inline-flex !important;
grid-area: toggle;
}
.header-tools {
grid-area: tools;
justify-content: flex-end;
}
.user-bar {
display: none !important;
}
.site-title {
grid-area: title;
font-size: .9rem;
margin: 0;
text-align: left;
min-width: 0;
}
.site-title-mobile {
display: inline !important;
}
.site-title-desktop {
display: none !important;
}
.trade-form-line.line-3 {
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
gap: .45rem !important;
}
.trade-form-line.line-3 .trade-field:first-child {
grid-column: 1 / -1 !important;
}
.card {
overflow: visible;
max-width: 100%;
}
}
+188
View File
@@ -0,0 +1,188 @@
/* Copyright (c) 2025-2026 马建军. All rights reserved.
* 交易记录与复盘 — 手机简洁列表 + 详情弹窗
*/
.records-page .records-mobile-list {
display: none;
}
.records-page .records-desktop-only {
display: block;
}
.records-mobile-item {
display: block;
width: 100%;
text-align: left;
border: 1px solid var(--card-border);
border-radius: 12px;
background: var(--card-inner);
padding: .75rem .85rem;
margin-bottom: .55rem;
cursor: pointer;
color: inherit;
font: inherit;
transition: border-color .2s, box-shadow .2s;
}
.records-mobile-item:hover,
.records-mobile-item:focus-visible {
border-color: var(--accent);
box-shadow: 0 0 0 1px rgba(56, 189, 248, .2);
outline: none;
}
.records-mobile-item-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: .5rem;
margin-bottom: .35rem;
}
.records-mobile-symbol {
font-size: .92rem;
font-weight: 600;
color: var(--text-title);
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.records-mobile-item-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: .35rem .5rem;
font-size: .72rem;
color: var(--text-muted);
margin-bottom: .3rem;
}
.records-mobile-item-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: .5rem;
}
.records-mobile-pnl {
font-size: .88rem;
font-weight: 600;
}
.records-mobile-pnl.is-profit { color: var(--profit); }
.records-mobile-pnl.is-loss { color: var(--loss); }
.records-mobile-pnl.is-flat { color: var(--text-muted); }
.records-mobile-chevron {
font-size: .72rem;
color: var(--accent);
white-space: nowrap;
}
.records-mobile-empty {
padding: 1.25rem .5rem;
text-align: center;
color: var(--text-muted);
font-size: .85rem;
}
.records-page .trade-switch-label.records-desktop-only {
display: flex;
}
#trade-detail-modal .records-detail-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: .55rem .75rem;
margin-bottom: 1rem;
}
#trade-detail-modal .records-detail-item label {
display: block;
font-size: .68rem;
color: var(--text-muted);
margin-bottom: .12rem;
}
#trade-detail-modal .records-detail-item div {
font-size: .84rem;
color: var(--text-primary);
line-height: 1.35;
word-break: break-word;
}
#trade-detail-modal .records-detail-item.wide {
grid-column: 1 / -1;
}
#trade-detail-modal .records-detail-actions {
display: flex;
flex-wrap: wrap;
gap: .45rem;
padding-top: .75rem;
border-top: 1px solid var(--table-border);
}
#trade-detail-modal .records-detail-actions a,
#trade-detail-modal .records-detail-actions button {
font-size: .78rem;
padding: .45rem .7rem;
border-radius: 8px;
text-decoration: none;
border: none;
cursor: pointer;
}
.records-review-mobile .records-mobile-item.is-emotion {
border-color: rgba(239, 68, 68, .35);
}
html:is([data-mobile="1"], .layout-phone) .records-page .records-mobile-list,
html:is([data-layout="phone"], .layout-phone) .records-page .records-mobile-list {
display: block;
}
html:is([data-mobile="1"], .layout-phone) .records-page .records-desktop-only,
html:is([data-layout="phone"], .layout-phone) .records-page .records-desktop-only {
display: none !important;
}
html:is([data-mobile="1"], .layout-phone) .records-page .records-trade-card .card-body,
html:is([data-layout="phone"], .layout-phone) .records-page .records-trade-card .card-body {
padding: 0;
}
html:is([data-mobile="1"], .layout-phone) .records-page .records-equity-card #equity-curve-chart,
html:is([data-layout="phone"], .layout-phone) .records-page .records-equity-card #equity-curve-chart {
min-height: 180px;
}
html:is([data-mobile="1"], .layout-phone) .records-page .preset-tabs,
html:is([data-layout="phone"], .layout-phone) .records-page .preset-tabs {
flex-wrap: wrap;
gap: .35rem;
}
html:is([data-mobile="1"], .layout-phone) .records-page .preset-tabs a,
html:is([data-layout="phone"], .layout-phone) .records-page .preset-tabs a {
flex: 1;
text-align: center;
min-width: 0;
padding: .45rem .35rem;
font-size: .75rem;
}
html:is([data-mobile="1"], .layout-phone) #review-modal .review-detail-headers,
html:is([data-mobile="1"], .layout-phone) #review-modal .review-detail-values,
html:is([data-layout="phone"], .layout-phone) #review-modal .review-detail-headers,
html:is([data-layout="phone"], .layout-phone) #review-modal .review-detail-values {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (pointer: coarse) and (max-width: 600px) {
.records-page .records-mobile-list { display: block; }
.records-page .records-desktop-only { display: none !important; }
}
+270 -9
View File
@@ -214,42 +214,42 @@ body {
} }
@media (max-width: 767px) { @media (max-width: 767px) {
.nav-toggle { html:not([data-mobile="1"]):not(.layout-phone) .nav-toggle {
display: inline-flex; display: inline-flex;
} }
.header-bar { html:not([data-mobile="1"]):not(.layout-phone) .header-bar {
grid-template-columns: auto 1fr; grid-template-columns: auto 1fr;
grid-template-areas: grid-template-areas:
"toggle tools" "toggle tools"
"user user"; "user user";
} }
.nav-toggle { grid-area: toggle; } html:not([data-mobile="1"]):not(.layout-phone) .nav-toggle { grid-area: toggle; }
.header-tools { grid-area: tools; justify-content: flex-end; } html:not([data-mobile="1"]):not(.layout-phone) .header-tools { grid-area: tools; justify-content: flex-end; }
.user-bar { html:not([data-mobile="1"]):not(.layout-phone) .user-bar {
grid-area: user; grid-area: user;
text-align: center; text-align: center;
width: 100%; width: 100%;
} }
.site-header { html:not([data-mobile="1"]):not(.layout-phone) .site-header {
padding: .85rem .75rem .75rem; padding: .85rem .75rem .75rem;
text-align: left; text-align: left;
} }
.site-title { html:not([data-mobile="1"]):not(.layout-phone) .site-title {
font-size: 1.15rem; font-size: 1.15rem;
margin-bottom: .65rem; margin-bottom: .65rem;
text-align: center; text-align: center;
} }
.site-title-sub { html:not([data-mobile="1"]):not(.layout-phone) .site-title-sub {
font-size: .58rem; font-size: .58rem;
letter-spacing: .1em; letter-spacing: .1em;
} }
.site-nav { html:not([data-mobile="1"]):not(.layout-phone) .site-nav {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
@@ -547,3 +547,264 @@ body.login-page {
padding: 1.75rem 1.25rem 1.5rem; padding: 1.75rem 1.25rem 1.5rem;
} }
} }
/* ── 设备布局:手机竖屏 / 平板横屏 ── */
.orientation-lock {
position: fixed;
inset: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: 1.5rem;
background: var(--modal-mask);
backdrop-filter: blur(6px);
}
.orientation-lock[hidden] {
display: none !important;
}
.orientation-lock-box {
max-width: 18rem;
padding: 1.75rem 1.25rem;
border-radius: 14px;
border: 1px solid var(--card-border);
background: var(--card-bg);
text-align: center;
box-shadow: var(--shadow-card-hover);
}
.orientation-lock-icon {
font-size: 2.5rem;
line-height: 1;
margin-bottom: .85rem;
color: var(--accent);
animation: orientation-spin 2.4s ease-in-out infinite;
}
.orientation-lock-box p {
margin: 0;
font-size: .95rem;
line-height: 1.55;
color: var(--text-title);
}
@keyframes orientation-spin {
0%, 100% { transform: rotate(0deg); }
50% { transform: rotate(90deg); }
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .nav-toggle {
display: inline-flex;
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .header-bar {
grid-template-columns: auto 1fr;
grid-template-areas:
"toggle tools"
"user user";
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .nav-toggle { grid-area: toggle; }
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .header-tools { grid-area: tools; justify-content: flex-end; }
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .user-bar {
grid-area: user;
text-align: center;
width: 100%;
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .site-header {
padding: .75rem .75rem .65rem;
text-align: left;
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .site-title {
font-size: 1.05rem;
margin-bottom: .5rem;
text-align: center;
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .site-title-sub {
display: none;
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .site-nav {
position: fixed;
top: 0;
left: 0;
width: min(86vw, 320px);
height: 100dvh;
flex-direction: column;
align-items: stretch;
justify-content: flex-start;
gap: .35rem;
padding: calc(var(--safe-top) + 3.5rem) 1rem 1.5rem;
background: var(--card-bg);
border-right: 1px solid var(--card-border);
box-shadow: var(--shadow-card-hover);
z-index: 100;
transform: translateX(-105%);
transition: transform .28s ease;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .site-nav.open {
transform: translateX(0);
}
html[data-layout="phone"]:not([data-mobile="1"]):not(.layout-phone) .site-nav a {
width: 100%;
text-align: left;
padding: .75rem 1rem;
font-size: .9rem;
min-height: var(--touch-min);
display: flex;
align-items: center;
border-radius: 10px;
}
html[data-layout="phone"] .main {
padding: .75rem .65rem 1.1rem;
}
html[data-layout="phone"] .split-grid {
grid-template-columns: 1fr;
gap: .85rem;
}
html[data-layout="phone"] .split-grid .card,
html[data-layout="phone"] .trade-split .card {
min-height: auto;
}
html[data-layout="phone"] .trade-top-bar-main {
flex-direction: column;
align-items: flex-start;
gap: .35rem;
}
html[data-layout="phone"] .trade-session-clock {
display: block;
font-size: .72rem;
line-height: 1.45;
}
html[data-layout="phone"] .session-clock-detail {
display: block;
margin-top: .15rem;
}
html[data-layout="phone"] .trade-top-hint {
font-size: .68rem;
line-height: 1.4;
}
html[data-layout="phone"] .pos-metrics {
grid-template-columns: repeat(2, 1fr);
}
html[data-layout="phone"] .pos-card-head {
flex-direction: column;
align-items: stretch;
}
html[data-layout="phone"] .pos-card-actions {
width: 100%;
justify-content: flex-end;
}
html[data-layout="phone"] .rec-sort-bar {
flex-direction: column;
align-items: stretch;
}
html[data-layout="phone"] .rec-sort-bar select {
width: 100%;
min-width: 0;
}
html[data-layout="phone"] #recommend .trade-table-wrap {
overflow-x: auto;
overflow-y: auto;
max-height: 52vh;
}
html[data-layout="phone"] .strategy-preview-table {
font-size: .68rem;
}
html[data-layout="tablet"][data-orientation="landscape"] .site-header {
padding: .85rem 1rem .75rem;
}
html[data-layout="tablet"][data-orientation="landscape"] .site-title {
font-size: 1.35rem;
margin-bottom: .85rem;
}
html[data-layout="tablet"][data-orientation="landscape"] .site-nav {
flex-wrap: nowrap;
overflow-x: auto;
justify-content: flex-start;
-webkit-overflow-scrolling: touch;
scrollbar-width: none;
}
html[data-layout="tablet"][data-orientation="landscape"] .site-nav::-webkit-scrollbar {
display: none;
}
html[data-layout="tablet"][data-orientation="landscape"] .site-nav a {
flex-shrink: 0;
padding: .48rem .75rem;
font-size: .8rem;
}
html[data-layout="tablet"][data-orientation="landscape"] .main {
padding: 1rem .85rem;
}
html[data-layout="tablet"][data-orientation="landscape"] .split-grid,
html[data-layout="tablet"][data-orientation="landscape"] .trade-split {
grid-template-columns: 1fr 1fr;
gap: 1rem;
align-items: stretch;
}
html[data-layout="tablet"][data-orientation="landscape"] .split-grid .card,
html[data-layout="tablet"][data-orientation="landscape"] .trade-split .card {
min-height: 380px;
}
html[data-layout="tablet"][data-orientation="landscape"] .trade-form-line.line-3 {
grid-template-columns: 1fr 1fr;
}
html[data-layout="tablet"][data-orientation="landscape"] .trade-form-line.line-3 .trade-field:first-child {
grid-column: 1 / -1;
}
html[data-layout="tablet"][data-orientation="landscape"] .pos-metrics {
grid-template-columns: repeat(4, 1fr);
}
html[data-layout="tablet"][data-orientation="landscape"] .trade-top-bar {
flex-direction: row;
align-items: flex-start;
}
html[data-layout="tablet"][data-orientation="landscape"] .trade-top-bar-actions {
width: auto;
flex-shrink: 0;
}
html[data-layout="tablet"][data-orientation="landscape"] .strategy-page .split-grid {
grid-template-columns: 1fr 1fr;
}
html[data-layout="tablet"][data-orientation="landscape"] .strategy-page .split-grid .card {
min-height: 420px;
}
+1 -1
View File
@@ -134,7 +134,7 @@
.trade-top-bar-actions{width:100%} .trade-top-bar-actions{width:100%}
.btn-ctp-sm{width:100%;min-height:44px} .btn-ctp-sm{width:100%;min-height:44px}
.trade-split .card{min-height:auto} .trade-split .card{min-height:auto}
.trade-form-line.line-3{grid-template-columns:1fr} html:not([data-mobile="1"]) .trade-form-line.line-3{grid-template-columns:1fr}
.trade-card-full{margin-bottom:1rem} .trade-card-full{margin-bottom:1rem}
.trade-table-wrap{max-height:320px} .trade-table-wrap{max-height:320px}
} }
+11 -1
View File
@@ -29,7 +29,9 @@
} }
function isMobileNav() { function isMobileNav() {
return window.matchMedia('(max-width: 767px)').matches; if (window.qihuoLayout && window.qihuoLayout.isPhone()) return true;
return document.documentElement.dataset.mobile === '1'
|| window.matchMedia('(max-width: 767px)').matches;
} }
toggle.addEventListener('click', function () { toggle.addEventListener('click', function () {
@@ -70,6 +72,14 @@
if (!isMobileNav()) closeNav(); if (!isMobileNav()) closeNav();
}); });
if (window.qihuoLayout) {
window.addEventListener('orientationchange', function () {
setTimeout(function () {
if (!isMobileNav()) closeNav();
}, 150);
});
}
document.addEventListener('keydown', function (e) { document.addEventListener('keydown', function (e) {
if (e.key === 'Escape') closeNav(); if (e.key === 'Escape') closeNav();
}); });
+102
View File
@@ -0,0 +1,102 @@
/* Copyright (c) 2025-2026 . All rights reserved.
* 专有软件 未经授权禁止复制传播转售
* 详见 LICENSE.zh-CN.txt
*/
(function () {
function isCoarsePointer() {
return window.matchMedia('(hover: none) and (pointer: coarse)').matches;
}
function isTabletUa() {
var ua = navigator.userAgent || '';
if (/iPad/i.test(ua)) return true;
if (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) return true;
if (/Android/i.test(ua) && !/Mobile/i.test(ua)) return true;
if (/Tablet|PlayBook|Silk/i.test(ua)) return true;
return false;
}
function isPhoneUa() {
var ua = navigator.userAgent || '';
if (isTabletUa()) return false;
if (/iPhone|iPod/i.test(ua)) return true;
if (/Android/i.test(ua) && /Mobile/i.test(ua)) return true;
if (/HarmonyOS|OpenHarmony/i.test(ua) && !/Tablet/i.test(ua)) return true;
if (/Mobile|Windows Phone|IEMobile|BlackBerry/i.test(ua)) return true;
return false;
}
function screenShortSide() {
return Math.min(window.screen.width || 0, window.screen.height || 0);
}
function detectLayout() {
var shortSide = screenShortSide();
var coarse = isCoarsePointer();
if (isPhoneUa()) return 'phone';
if (isTabletUa()) return 'tablet';
if (shortSide > 0 && shortSide < 600) return 'phone';
if (shortSide >= 600 && shortSide <= 1100 && coarse) return 'tablet';
if (window.innerWidth <= 767) return 'phone';
if (window.innerWidth <= 1100 && coarse) return 'tablet';
return 'desktop';
}
function updateLayoutState() {
var root = document.documentElement;
var layout = detectLayout();
var isPhone = layout === 'phone';
var landscape = window.innerWidth > window.innerHeight;
root.dataset.layout = layout;
root.dataset.mobile = isPhone ? '1' : '0';
root.dataset.orientation = isPhone ? 'portrait' : (landscape ? 'landscape' : 'portrait');
root.classList.toggle('layout-phone', isPhone);
root.classList.toggle('layout-tablet', layout === 'tablet');
var nav = document.getElementById('site-nav');
var userBar = document.querySelector('.user-bar');
if (nav && userBar && isPhone) {
nav.setAttribute('data-user-label', (userBar.textContent || '').replace(/\s+/g, ' ').trim());
}
var overlay = document.getElementById('orientation-lock');
var msg = document.getElementById('orientation-lock-msg');
if (!overlay) return;
if (isPhone) {
if (landscape) {
overlay.hidden = false;
if (msg) msg.textContent = '请竖屏使用';
} else {
overlay.hidden = true;
}
return;
}
if (layout === 'tablet' && root.dataset.orientation === 'portrait') {
overlay.hidden = false;
if (msg) msg.textContent = '平板请旋转至横屏使用';
return;
}
overlay.hidden = true;
}
window.qihuoLayout = {
isPhone: function () { return document.documentElement.dataset.mobile === '1'; },
isTablet: function () { return document.documentElement.dataset.layout === 'tablet'; },
refresh: updateLayoutState,
};
updateLayoutState();
window.addEventListener('resize', updateLayoutState);
window.addEventListener('orientationchange', function () {
setTimeout(updateLayoutState, 150);
});
document.addEventListener('visibilitychange', function () {
if (!document.hidden) updateLayoutState();
});
})();
+96
View File
@@ -0,0 +1,96 @@
/* Copyright (c) 2025-2026 . All rights reserved.
* 交易记录 手机简洁列表与详情弹窗
*/
(function () {
function esc(v) {
if (v === null || v === undefined || v === '') return '-';
return String(v);
}
function fmtTime(v) {
if (!v) return '-';
return String(v).replace('T', ' ').slice(0, 16);
}
function pnlClass(v) {
var n = parseFloat(v);
if (isNaN(n) || n === 0) return 'is-flat';
return n > 0 ? 'is-profit' : 'is-loss';
}
function showTradeModal(data) {
var mask = document.getElementById('trade-detail-modal');
var body = document.getElementById('trade-detail-modal-body');
if (!mask || !body) return;
var fields = [
{ label: '品种', value: esc(data.symbol), wide: false },
{ label: '合约', value: esc(data.symbol_code), wide: false },
{ label: '类型', value: esc(data.monitor_type) + ' · ' + esc(data.source), wide: false },
{ label: '方向', value: esc(data.direction), wide: false },
{ label: '成交价', value: esc(data.entry_price), wide: false },
{ label: '手数', value: esc(data.lots), wide: false },
{ label: '止损', value: esc(data.stop_loss), wide: false },
{ label: '止盈', value: esc(data.take_profit), wide: false },
{ label: '保证金', value: data.margin != null ? esc(data.margin) : '-', wide: false },
{ label: '保证金占比', value: data.margin_pct != null ? esc(data.margin_pct) + '%' : '-', wide: false },
{ label: '持仓分钟', value: esc(data.holding_minutes), wide: false },
{ label: '开仓时间', value: fmtTime(data.open_time), wide: false },
{ label: '平仓时间', value: fmtTime(data.close_time), wide: false },
{ label: '盈亏(元)', value: esc(data.pnl), wide: false },
{ label: '手续费', value: esc(data.fee), wide: false },
{ label: '净盈亏', value: esc(data.pnl_net), wide: false },
{ label: '最新资金', value: esc(data.equity_after), wide: false },
{ label: '结果', value: esc(data.result) + (data.verified ? ' · 已核对' : ''), wide: true }
];
var html = '<div class="records-detail-grid">';
fields.forEach(function (f) {
html += '<div class="records-detail-item' + (f.wide ? ' wide' : '') + '">';
html += '<label>' + f.label + '</label><div>' + f.value + '</div></div>';
});
html += '</div>';
html += '<div class="records-detail-actions">';
if (data.fill_review_url) {
html += '<a href="' + data.fill_review_url + '" class="btn-fill">填入复盘</a>';
}
if (data.del_url) {
html += '<a href="' + data.del_url + '" class="btn-del" onclick="return confirm(\'删除?\')">删除</a>';
}
html += '</div>';
body.innerHTML = html;
mask.classList.add('show');
}
function bindTradeModal() {
var mask = document.getElementById('trade-detail-modal');
if (!mask) return;
var closeBtn = mask.querySelector('.modal-close');
if (closeBtn) {
closeBtn.addEventListener('click', function () {
mask.classList.remove('show');
});
}
mask.addEventListener('click', function (e) {
if (e.target === mask) mask.classList.remove('show');
});
document.querySelectorAll('.records-trade-item').forEach(function (btn) {
btn.addEventListener('click', function () {
try {
showTradeModal(JSON.parse(btn.getAttribute('data-trade')));
} catch (err) { /* ignore */ }
});
});
}
function bootRecordsPage() {
if (!document.querySelector('.records-page')) return;
bindTradeModal();
}
if (window.qihuoPageBoot) window.qihuoPageBoot(bootRecordsPage, '.records-page');
else if (window.qihuoOnPageLoad) window.qihuoOnPageLoad(bootRecordsPage);
else document.addEventListener('DOMContentLoaded', bootRecordsPage);
})();
+39 -8
View File
@@ -24,11 +24,32 @@
} }
} catch (e) { /* ignore */ } } catch (e) { /* ignore */ }
</script> </script>
<script src="{{ url_for('static', filename='js/theme.js') }}"></script> <script>
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}"> (function () {
<link rel="stylesheet" href="{{ url_for('static', filename='css/tech.css') }}"> var ua = navigator.userAgent || '';
<link rel="stylesheet" href="{{ url_for('static', filename='css/responsive.css') }}"> var isIpad = /iPad/i.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
var isTabletUa = isIpad || (/Android/i.test(ua) && !/Mobile/i.test(ua));
var isPhoneUa = !isTabletUa && (/iPhone|iPod|Android.*Mobile|HarmonyOS|OpenHarmony|Mobile/i.test(ua));
var s = Math.min(window.screen.width || 0, window.screen.height || 0);
var coarse = window.matchMedia('(hover: none) and (pointer: coarse)').matches;
var layout = 'desktop';
if (isPhoneUa || (s > 0 && s < 600)) layout = 'phone';
else if (isTabletUa || (s >= 600 && s <= 1100 && coarse)) layout = 'tablet';
else if (window.innerWidth <= 767) layout = 'phone';
var root = document.documentElement;
root.dataset.layout = layout;
root.dataset.mobile = layout === 'phone' ? '1' : '0';
root.dataset.orientation = layout === 'phone' ? 'portrait' : (window.innerWidth >= window.innerHeight ? 'landscape' : 'portrait');
if (layout === 'phone') root.classList.add('layout-phone');
else if (layout === 'tablet') root.classList.add('layout-tablet');
})();
</script>
<script src="{{ url_for('static', filename='js/theme.js') }}?v={{ asset_v }}"></script>
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}?v={{ asset_v }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/tech.css') }}?v={{ asset_v }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/responsive.css') }}?v={{ asset_v }}">
{% block extra_css %}{% endblock %} {% block extra_css %}{% endblock %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/mobile.css') }}?v={{ asset_v }}">
</head> </head>
<body> <body>
<div class="tech-bg" aria-hidden="true"> <div class="tech-bg" aria-hidden="true">
@@ -43,6 +64,10 @@
<button type="button" class="nav-toggle" id="nav-toggle" aria-label="打开菜单" aria-expanded="false" aria-controls="site-nav"> <button type="button" class="nav-toggle" id="nav-toggle" aria-label="打开菜单" aria-expanded="false" aria-controls="site-nav">
<span></span><span></span><span></span> <span></span><span></span><span></span>
</button> </button>
<h1 class="site-title">
<span class="site-title-mobile">期货监控</span>
<span class="site-title-desktop">国内期货 · 交易复盘系统<span class="site-title-sub">Position Management · Disciplined Execution</span></span>
</h1>
<div class="header-tools"> <div class="header-tools">
<div class="theme-switch" role="group" aria-label="主题模式"> <div class="theme-switch" role="group" aria-label="主题模式">
<button type="button" class="theme-switch-btn" data-theme-pick="dark">深色</button> <button type="button" class="theme-switch-btn" data-theme-pick="dark">深色</button>
@@ -53,7 +78,6 @@
<div class="user-bar">{{ session.username or '用户' }}<a href="{{ url_for('logout') }}">退出</a></div> <div class="user-bar">{{ session.username or '用户' }}<a href="{{ url_for('logout') }}">退出</a></div>
</div> </div>
<p class="pwa-ios-hint" id="pwa-ios-hint">iOS 安装:Safari 浏览器点击底部分享按钮,选择「添加到主屏幕」。</p> <p class="pwa-ios-hint" id="pwa-ios-hint">iOS 安装:Safari 浏览器点击底部分享按钮,选择「添加到主屏幕」。</p>
<h1 class="site-title">国内期货 · 交易复盘系统<span class="site-title-sub">Position Management · Disciplined Execution</span></h1>
<button type="button" class="nav-backdrop" id="nav-backdrop" aria-label="关闭菜单" hidden></button> <button type="button" class="nav-backdrop" id="nav-backdrop" aria-label="关闭菜单" hidden></button>
<nav class="site-nav" id="site-nav"> <nav class="site-nav" id="site-nav">
<a href="{{ url_for('positions') }}" class="{% if request.endpoint in ('positions', 'trade_page', 'recommend_page') %}active{% endif %}">下单监控</a> <a href="{{ url_for('positions') }}" class="{% if request.endpoint in ('positions', 'trade_page', 'recommend_page') %}active{% endif %}">下单监控</a>
@@ -73,9 +97,16 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
</main> </main>
</div> </div>
<script src="{{ url_for('static', filename='js/symbol.js') }}"></script> <div id="orientation-lock" class="orientation-lock" hidden>
<script src="{{ url_for('static', filename='js/nav.js') }}"></script> <div class="orientation-lock-box">
<script src="{{ url_for('static', filename='js/pwa.js') }}"></script> <div class="orientation-lock-icon" aria-hidden="true"></div>
<p id="orientation-lock-msg">请旋转设备</p>
</div>
</div>
<script src="{{ url_for('static', filename='js/orientation.js') }}?v={{ asset_v }}"></script>
<script src="{{ url_for('static', filename='js/symbol.js') }}?v={{ asset_v }}"></script>
<script src="{{ url_for('static', filename='js/nav.js') }}?v={{ asset_v }}"></script>
<script src="{{ url_for('static', filename='js/pwa.js') }}?v={{ asset_v }}"></script>
{% block extra_js %}{% endblock %} {% block extra_js %}{% endblock %}
</body> </body>
</html> </html>
+107 -5
View File
@@ -1,7 +1,11 @@
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #} {# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}交易记录与复盘 - 国内期货 · 交易复盘系统{% endblock %} {% block title %}交易记录与复盘 - 国内期货 · 交易复盘系统{% endblock %}
{% block extra_css %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/records.css') }}?v={{ asset_v }}">
{% endblock %}
{% block content %} {% block content %}
<div class="records-page">
<div class="card records-equity-card" style="margin-bottom:1.25rem"> <div class="card records-equity-card" style="margin-bottom:1.25rem">
<h2>资金曲线</h2> <h2>资金曲线</h2>
<div class="card-body"> <div class="card-body">
@@ -20,11 +24,61 @@
{% else %} {% else %}
<p class="hint" style="margin-top:0">CTP 未连接时仅显示本地数据库记录;连接后打开本页会自动同步柜台成交。</p> <p class="hint" style="margin-top:0">CTP 未连接时仅显示本地数据库记录;连接后打开本页会自动同步柜台成交。</p>
{% endif %} {% endif %}
<label class="trade-switch-label"> <label class="trade-switch-label records-desktop-only">
<input type="checkbox" id="trade-edit-switch"> <input type="checkbox" id="trade-edit-switch">
<span>修改/核对开关(开启后可编辑关键字段)</span> <span>修改/核对开关(开启后可编辑关键字段)</span>
</label> </label>
<div class="trade-table-wrap"> <div class="records-mobile-list" id="records-trade-mobile">
{% for t in trades %}
<button type="button" class="records-mobile-item records-trade-item" data-trade='{{ {
"symbol": t.symbol_name or t.symbol,
"symbol_code": t.symbol,
"monitor_type": t.monitor_type,
"source": "柜台" if t.source == "ctp" else "本地",
"direction": "做多" if t.direction == "long" else "做空",
"entry_price": t.entry_price,
"stop_loss": t.stop_loss,
"take_profit": t.take_profit,
"lots": t.lots,
"margin": t.margin,
"margin_pct": t.margin_pct,
"holding_minutes": t.holding_minutes or 0,
"open_time": t.open_time,
"close_time": t.close_time,
"pnl": t.pnl,
"fee": t.fee,
"pnl_net": t.pnl_net,
"equity_after": t.equity_after,
"result": t.result,
"verified": t.verified,
"fill_review_url": url_for("fill_review_from_trade", tid=t.id),
"del_url": url_for("del_trade", tid=t.id)
} | tojson }}'>
<div class="records-mobile-item-head">
<span class="records-mobile-symbol">{{ t.symbol_name or t.symbol }}</span>
<span class="badge dir">{{ '做多' if t.direction == 'long' else '做空' }}</span>
</div>
<div class="records-mobile-item-meta">
<span>{{ (t.close_time or t.open_time or '')[:16].replace('T', ' ') }}</span>
{% if t.result == '止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '止损' %}<span class="badge loss">{{ t.result }}</span>
{% elif t.result in ('移动止盈', '保本止盈') %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '手动平仓' %}<span class="badge result-manual">{{ t.result }}</span>
{% else %}<span class="badge result-external">{{ t.result }}</span>{% endif %}
<span>{{ '柜台' if t.source == 'ctp' else '本地' }}</span>
</div>
<div class="records-mobile-item-foot">
<span class="records-mobile-pnl {{ 'is-profit' if t.pnl_net and t.pnl_net > 0 else ('is-loss' if t.pnl_net and t.pnl_net < 0 else 'is-flat') }}">
净盈亏 {{ t.pnl_net if t.pnl_net is not none else '-' }}
</span>
<span class="records-mobile-chevron">查看详情 </span>
</div>
</button>
{% else %}
<p class="records-mobile-empty">暂无交易记录</p>
{% endfor %}
</div>
<div class="trade-table-wrap records-desktop-only">
<table class="trade-table"> <table class="trade-table">
<thead> <thead>
<tr> <tr>
@@ -243,7 +297,45 @@
<button type="submit" class="btn-primary">筛选</button> <button type="submit" class="btn-primary">筛选</button>
</form> </form>
{% endif %} {% endif %}
<div class="card-scroll"> <div class="records-mobile-list records-review-mobile">
{% for r in reviews %}
<button type="button" class="records-mobile-item review-view-btn{% if r.is_emotion %} is-emotion{% endif %}" data-review='{{ {
"symbol": r.symbol_name or r.symbol, "symbol_code": r.symbol,
"direction": "做多" if r.direction=="long" else "做空",
"lots": r.lots, "timeframe": r.timeframe,
"entry_price": r.entry_price, "stop_loss": r.stop_loss, "take_profit": r.take_profit,
"close_price": r.close_price,
"open_time": r.open_time, "close_time": r.close_time,
"holding_duration": r.holding_duration,
"initial_pnl": r.initial_pnl, "actual_pnl": r.actual_pnl, "pnl": r.pnl,
"fee": r.fee, "pnl_net": r.pnl_net,
"open_type": r.open_type,
"exit_trigger": r.exit_trigger, "exit_supplement": r.exit_supplement,
"watch_after_breakeven": r.watch_after_breakeven,
"new_position_while_occupied": r.new_position_while_occupied,
"is_emotion": r.is_emotion, "behavior_tags": r.behavior_tags,
"notes": r.notes, "screenshot": r.screenshot
} | tojson }}'>
<div class="records-mobile-item-head">
<span class="records-mobile-symbol">{{ r.symbol_name or r.symbol }}</span>
<span class="badge dir">{{ '多' if r.direction == 'long' else '空' }}</span>
</div>
<div class="records-mobile-item-meta">
<span>{{ r.close_time[:16].replace('T', ' ') if r.close_time else '' }}</span>
{% if r.is_emotion %}<span class="badge emotion">情绪单</span>{% endif %}
</div>
<div class="records-mobile-item-foot">
<span class="records-mobile-pnl {{ 'is-profit' if r.pnl_net and r.pnl_net > 0 else ('is-loss' if r.pnl_net and r.pnl_net < 0 else 'is-flat') }}">
净盈亏 {{ r.pnl_net if r.pnl_net is not none else '-' }}
</span>
<span class="records-mobile-chevron">查看详情 </span>
</div>
</button>
{% else %}
<p class="records-mobile-empty">暂无复盘记录</p>
{% endfor %}
</div>
<div class="card-scroll records-desktop-only">
<table> <table>
<thead> <thead>
<tr> <tr>
@@ -307,6 +399,14 @@
</div> </div>
</div> </div>
<div id="trade-detail-modal" class="modal-mask">
<div class="modal-box review-modal-fullscreen">
<span class="modal-close"></span>
<h3>交易详情</h3>
<div id="trade-detail-modal-body" class="review-modal-body"></div>
</div>
</div>
{% if auto_records %} {% if auto_records %}
<div class="card" style="margin-top:1rem"> <div class="card" style="margin-top:1rem">
<h2>系统自动记录(止盈/止损)</h2> <h2>系统自动记录(止盈/止损)</h2>
@@ -327,13 +427,15 @@
</table> </table>
</div> </div>
{% endif %} {% endif %}
</div>
{% endblock %} {% endblock %}
{% block extra_js %} {% block extra_js %}
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script> <script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
<script>window.__EQUITY_CURVE__ = {{ equity_curve | default([]) | tojson }};</script> <script>window.__EQUITY_CURVE__ = {{ equity_curve | default([]) | tojson }};</script>
<script src="{{ url_for('static', filename='js/equity_curve.js') }}"></script> <script src="{{ url_for('static', filename='js/equity_curve.js') }}"></script>
<script src="{{ url_for('static', filename='js/review.js') }}"></script> <script src="{{ url_for('static', filename='js/review.js') }}?v={{ asset_v }}"></script>
<script src="{{ url_for('static', filename='js/trades.js') }}"></script> <script src="{{ url_for('static', filename='js/records.js') }}?v={{ asset_v }}"></script>
<script src="{{ url_for('static', filename='js/trades.js') }}?v={{ asset_v }}"></script>
{% if prefill %} {% if prefill %}
<script> <script>
function bootReviewPrefill() { function bootReviewPrefill() {
+10 -5
View File
@@ -4,8 +4,13 @@
{% block extra_css %} {% block extra_css %}
<style> <style>
.settings-page{display:flex;flex-direction:column;gap:1.25rem} .settings-page{display:flex;flex-direction:column;gap:1.25rem}
.settings-page .split-grid{margin-bottom:0} .settings-page .split-grid{margin-bottom:0;align-items:start}
.settings-page .split-grid .card{margin-bottom:0;min-height:100%;height:100%;display:flex;flex-direction:column} .settings-page .split-grid .card:not(.settings-fold){margin-bottom:0;min-height:100%;height:100%;display:flex;flex-direction:column}
.settings-page .split-grid .settings-fold.card,
.settings-page .split-grid .settings-ctp-fold.card{
margin-bottom:0;min-height:auto !important;height:auto !important;align-self:start;
display:flex;flex-direction:column;
}
.settings-page .split-grid .card > form, .settings-page .split-grid .card > form,
.settings-page .split-grid .card > .card-inner, .settings-page .split-grid .card > .card-inner,
.settings-page .split-grid .settings-fold-body > form, .settings-page .split-grid .settings-fold-body > form,
@@ -122,7 +127,7 @@
.settings-ai-daily-grid{grid-template-columns:1fr} .settings-ai-daily-grid{grid-template-columns:1fr}
} }
.settings-page .settings-fold.card{padding:0;overflow:hidden} .settings-page .settings-fold.card{padding:0;overflow:hidden}
.settings-page .split-grid .settings-fold.card{min-height:auto;height:auto} .settings-page .split-grid .settings-fold.card{min-height:auto;height:auto;align-self:start}
.settings-fold-head{ .settings-fold-head{
width:100%;display:flex;align-items:center;justify-content:space-between;gap:.75rem; width:100%;display:flex;align-items:center;justify-content:space-between;gap:.75rem;
padding:1rem 1rem .85rem;margin:0;border:none;background:transparent;cursor:pointer; padding:1rem 1rem .85rem;margin:0;border:none;background:transparent;cursor:pointer;
@@ -140,7 +145,7 @@
} }
.settings-fold-chevron{flex-shrink:0;font-size:.72rem;color:var(--text-muted);transition:transform .2s ease} .settings-fold-chevron{flex-shrink:0;font-size:.72rem;color:var(--text-muted);transition:transform .2s ease}
.settings-fold.is-collapsed .settings-fold-chevron{transform:rotate(-90deg)} .settings-fold.is-collapsed .settings-fold-chevron{transform:rotate(-90deg)}
.settings-fold-body{padding:0 1rem 1rem;flex:1;display:flex;flex-direction:column} .settings-fold-body{padding:0 1rem 1rem;display:flex;flex-direction:column}
.settings-fold.is-collapsed .settings-fold-body{display:none} .settings-fold.is-collapsed .settings-fold-body{display:none}
.settings-admin-row .settings-fold-head{padding:.75rem .85rem .6rem} .settings-admin-row .settings-fold-head{padding:.75rem .85rem .6rem}
.settings-admin-row .settings-fold-title{font-size:.95rem} .settings-admin-row .settings-fold-title{font-size:.95rem}
@@ -607,5 +612,5 @@
</div> </div>
{% endblock %} {% endblock %}
{% block extra_js %} {% block extra_js %}
<script src="{{ url_for('static', filename='js/settings.js') }}"></script> <script src="{{ url_for('static', filename='js/settings.js') }}?v={{ asset_v }}"></script>
{% endblock %} {% endblock %}
+5 -1
View File
@@ -8,7 +8,7 @@
.strategy-preview{background:var(--card-inner);border:1px solid var(--card-border);border-radius:8px;padding:.65rem .85rem;font-size:.78rem;line-height:1.5;margin-top:.75rem;max-height:360px;overflow:auto} .strategy-preview{background:var(--card-inner);border:1px solid var(--card-border);border-radius:8px;padding:.65rem .85rem;font-size:.78rem;line-height:1.5;margin-top:.75rem;max-height:360px;overflow:auto}
.strategy-preview .trend-summary{margin-bottom:.45rem;color:var(--text-title);font-size:.8rem;line-height:1.55} .strategy-preview .trend-summary{margin-bottom:.45rem;color:var(--text-title);font-size:.8rem;line-height:1.55}
.strategy-preview .trend-detail{margin-bottom:.55rem;color:var(--text-muted);font-size:.75rem;line-height:1.5} .strategy-preview .trend-detail{margin-bottom:.55rem;color:var(--text-muted);font-size:.75rem;line-height:1.5}
.strategy-preview-table{width:100%;border-collapse:collapse;font-size:.72rem} .strategy-preview-table{width:100%;border-collapse:collapse;font-size:.72rem;min-width:520px}
.strategy-preview-table th,.strategy-preview-table td{padding:.35rem .4rem;border-bottom:1px solid var(--table-border);text-align:right;white-space:nowrap} .strategy-preview-table th,.strategy-preview-table td{padding:.35rem .4rem;border-bottom:1px solid var(--table-border);text-align:right;white-space:nowrap}
.strategy-preview-table th:first-child,.strategy-preview-table td:first-child{text-align:left} .strategy-preview-table th:first-child,.strategy-preview-table td:first-child{text-align:left}
.strategy-preview-table thead th{color:var(--text-muted);font-weight:600;background:var(--list-item-bg)} .strategy-preview-table thead th{color:var(--text-muted);font-weight:600;background:var(--list-item-bg)}
@@ -148,6 +148,7 @@
{% endif %} {% endif %}
<h3 style="font-size:.85rem;margin:1rem 0 .45rem">活跃滚仓组</h3> <h3 style="font-size:.85rem;margin:1rem 0 .45rem">活跃滚仓组</h3>
{% if roll_groups %} {% if roll_groups %}
<div class="table-responsive">
<table class="strategy-preview-table"> <table class="strategy-preview-table">
<thead><tr> <thead><tr>
<th>ID</th><th>品种</th><th>方向</th><th>腿数</th><th>首仓TP</th><th>当前SL</th><th>当前均价</th><th>止盈盈利(元)</th> <th>ID</th><th>品种</th><th>方向</th><th>腿数</th><th>首仓TP</th><th>当前SL</th><th>当前均价</th><th>止盈盈利(元)</th>
@@ -167,11 +168,13 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
{% else %} {% else %}
<p class="hint text-muted">暂无</p> <p class="hint text-muted">暂无</p>
{% endif %} {% endif %}
<h3 style="font-size:.85rem;margin:1rem 0 .45rem">最近滚仓腿</h3> <h3 style="font-size:.85rem;margin:1rem 0 .45rem">最近滚仓腿</h3>
{% if roll_legs %} {% if roll_legs %}
<div class="table-responsive">
<table class="strategy-preview-table"> <table class="strategy-preview-table">
<thead><tr> <thead><tr>
<th>#</th><th></th><th>方式</th><th>手数</th><th>触发/限价</th><th>新SL</th><th>状态</th><th>操作</th> <th>#</th><th></th><th>方式</th><th>手数</th><th>触发/限价</th><th>新SL</th><th>状态</th><th>操作</th>
@@ -191,6 +194,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
{% else %} {% else %}
<p class="hint text-muted">暂无</p> <p class="hint text-muted">暂无</p>
{% endif %} {% endif %}
+1 -1
View File
@@ -2,7 +2,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}下单监控 - 国内期货 · 交易复盘系统{% endblock %} {% block title %}下单监控 - 国内期货 · 交易复盘系统{% endblock %}
{% block extra_css %} {% block extra_css %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/trade.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/trade.css') }}?v={{ asset_v }}">
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="trade-page"> <div class="trade-page">