From 9b29e19d7852af9320ac80b4d1ac20becd483b93 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Sun, 29 Mar 2026 11:55:16 +0800 Subject: [PATCH] 1 --- frontend/trading.html | 130 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 118 insertions(+), 12 deletions(-) diff --git a/frontend/trading.html b/frontend/trading.html index d8411e4..4d703df 100644 --- a/frontend/trading.html +++ b/frontend/trading.html @@ -150,6 +150,49 @@ grid-template-columns: 1fr; } } + + /* Admin Dropdown */ + .admin-dropdown { + position: relative; + } + + .admin-menu { + position: absolute; + top: 100%; + right: 0; + margin-top: 8px; + background: var(--bg-primary); + border: 1px solid var(--border); + border-radius: var(--radius-md); + box-shadow: var(--shadow-lg); + min-width: 200px; + z-index: 1000; + } + + .admin-menu-item { + display: block; + width: 100%; + padding: 12px 16px; + background: none; + border: none; + text-align: left; + font-size: 14px; + color: var(--text-primary); + cursor: pointer; + transition: all 0.2s; + } + + .admin-menu-item:hover { + background: var(--bg-secondary); + } + + .admin-menu-item:first-child { + border-radius: var(--radius-md) var(--radius-md) 0 0; + } + + .admin-menu-item:last-child { + border-radius: 0 0 var(--radius-md) var(--radius-md); + } @@ -158,7 +201,7 @@ -
-
已用保证金
-
${{ account.used_margin ? account.used_margin.toLocaleString() : '0' }}
-
持仓价值
${{ account.total_position_value ? account.total_position_value.toLocaleString() : '0' }}
已实现盈亏
-
- ${{ account.realized_pnl ? account.realized_pnl.toLocaleString() : '0' }} +
+ ${{ stats.total_pnl ? stats.total_pnl.toLocaleString() : '0' }}
{{ stats.total_trades || 0 }} 笔交易
+
+
收益率
+
+ {{ stats.total_pnl_percent >= 0 ? '+' : '' }}{{ stats.total_pnl_percent ? stats.total_pnl_percent.toFixed(2) : '0.00' }}% +
+
初始资金: $10,000
+
@@ -472,7 +524,12 @@ current_total_leverage: 0, max_total_leverage: 10 }, - orders: [] + orders: [], + adminMode: false, + showAdminMenu: false, + adminPassword: '223388', + titleClickCount: 0, + titleClickTimer: null }; }, computed: { @@ -483,7 +540,10 @@ return this.orders.filter(o => o.status === 'pending'); }, orderHistory() { - return this.orders.filter(o => o.status === 'closed'); + // 包含所有已关闭的订单:closed_tp, closed_sl, closed_be, closed_ts, closed_manual, cancelled + return this.orders.filter(o => + o.status.startsWith('closed') || o.status === 'cancelled' + ); } }, methods: { @@ -633,10 +693,56 @@ 'signal': '信号' }; return map[reason] || reason || '-'; + }, + + handleTitleClick() { + this.titleClickCount++; + if (this.titleClickTimer) { + clearTimeout(this.titleClickTimer); + } + this.titleClickTimer = setTimeout(() => { + this.titleClickCount = 0; + }, 2000); + + if (this.titleClickCount === 3) { + this.titleClickCount = 0; + this.promptAdminMode(); + } + }, + + promptAdminMode() { + if (this.adminMode) { + this.adminMode = false; + this.showAdminMenu = false; + alert('管理员模式已关闭'); + } else { + const password = prompt('请输入管理员密码:'); + if (password === this.adminPassword) { + this.adminMode = true; + alert('管理员模式已开启'); + } else if (password !== null) { + alert('密码错误'); + } + } + }, + + toggleAdminMenu() { + this.showAdminMenu = !this.showAdminMenu; + }, + + toggleAdminMode() { + this.promptAdminMode(); } }, mounted() { this.refreshData(); + + // 点击外部关闭管理菜单 + document.addEventListener('click', (e) => { + if (this.showAdminMenu && !e.target.closest('.admin-dropdown')) { + this.showAdminMenu = false; + } + }); } }).mount('#app');