This commit is contained in:
aaron 2026-03-22 11:55:16 +08:00
parent cb6ab397fe
commit 83c9033967

View File

@ -2,74 +2,82 @@
<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.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Hyperliquid 交易监控 | AI Agent</title> <title>Hyperliquid 交易监控 | AI Agent</title>
<link rel="stylesheet" href="/static/css/style.css"> <link rel="stylesheet" href="/static/css/style.css">
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
<style> <style>
* { /* 防止横向滚动 */
margin: 0; html, body {
overflow-x: hidden;
max-width: 100vw;
}
/* 覆盖全局 #app 样式 */
#app {
height: auto;
display: block;
align-items: initial;
justify-content: initial;
padding: 0; padding: 0;
box-sizing: border-box; overflow-x: hidden;
} }
body { .trading-page {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0d1117;
color: #c9d1d9;
min-height: 100vh; min-height: 100vh;
} background: var(--bg-primary);
.container {
max-width: 1400px;
margin: 0 auto;
padding: 20px; padding: 20px;
} }
.header { .trading-container {
max-width: 1400px;
margin: 0 auto;
}
/* 固定顶部区域 */
.sticky-header {
position: sticky;
top: 0;
z-index: 100;
background: var(--bg-primary);
padding-bottom: 10px;
}
.trading-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-bottom: 24px; margin-bottom: 20px;
padding-bottom: 16px; padding: 10px 0 20px 0;
border-bottom: 1px solid #30363d; border-bottom: 1px solid var(--border);
background: var(--bg-primary);
} }
.title { .trading-title {
font-size: 24px; font-size: 24px;
font-weight: 600; font-weight: 300;
color: #58a6ff; color: var(--text-primary);
user-select: none;
cursor: default;
} }
.status-badge { .trading-title span {
padding: 4px 12px; color: var(--accent);
border-radius: 20px;
font-size: 12px;
font-weight: 500;
}
.status-enabled {
background: #238636;
color: #3fb950;
}
.status-disabled {
background: #8c959f;
color: #6e7681;
} }
.refresh-btn { .refresh-btn {
padding: 8px 16px; padding: 8px 16px;
background: #21262d; background: transparent;
border: 1px solid #30363d; border: 1px solid var(--accent);
color: #c9d1d9; color: var(--accent);
border-radius: 6px; font-size: 14px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s;
} }
.refresh-btn:hover { .refresh-btn:hover {
background: #30363d; background: var(--accent);
color: var(--bg-primary);
} }
.refresh-btn.loading { .refresh-btn.loading {
@ -77,48 +85,69 @@
cursor: wait; cursor: wait;
} }
/* 账户信息卡片 */ /* 状态标签 */
.status-badge {
display: inline-block;
padding: 4px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 500;
}
.status-enabled {
background: rgba(0, 255, 65, 0.1);
color: #00ff41;
border: 1px solid rgba(0, 255, 65, 0.3);
}
.status-disabled {
background: rgba(128, 128, 128, 0.1);
color: var(--text-secondary);
border: 1px solid var(--border);
}
/* 统计卡片 */
.stats-grid { .stats-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px; gap: 16px;
margin-bottom: 24px; margin-bottom: 20px;
} }
.stat-card { .stat-card {
background: #161b22; background: var(--bg-secondary);
border: 1px solid #30363d; border: 1px solid var(--border);
border-radius: 8px; border-radius: 4px;
padding: 20px; padding: 16px;
} }
.stat-label { .stat-label {
font-size: 12px; font-size: 12px;
color: #8b949e; color: var(--text-secondary);
margin-bottom: 8px; margin-bottom: 6px;
} }
.stat-value { .stat-value {
font-size: 24px; font-size: 24px;
font-weight: 600; font-weight: 300;
color: #58a6ff; color: var(--accent);
} }
.stat-value.positive { .stat-value.positive {
color: #3fb950; color: var(--accent);
} }
.stat-value.negative { .stat-value.negative {
color: #f85149; color: #ef4444;
} }
.stat-value.warning { .stat-value.warning {
color: #d29922; color: #f59e0b;
} }
.stat-sub { .stat-sub {
font-size: 11px; font-size: 11px;
color: #8b949e; color: var(--text-secondary);
margin-top: 4px; margin-top: 4px;
} }
@ -130,10 +159,11 @@
margin-bottom: 24px; margin-bottom: 24px;
} }
/* 面板 */
.panel { .panel {
background: #161b22; background: var(--bg-secondary);
border: 1px solid #30363d; border: 1px solid var(--border);
border-radius: 8px; border-radius: 4px;
overflow: hidden; overflow: hidden;
} }
@ -142,29 +172,29 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 16px 20px; padding: 16px 20px;
border-bottom: 1px solid #30363d; border-bottom: 1px solid var(--border);
background: #0d1117; background: var(--bg-primary);
} }
.panel-title { .panel-title {
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: #c9d1d9; color: var(--text-primary);
} }
.panel-count { .panel-count {
font-size: 12px; font-size: 12px;
color: #8b949e; color: var(--text-secondary);
} }
.panel-body { .panel-body {
padding: 0; padding: 0;
} }
/* 列表样式 */ /* 列表 */
.list-item { .list-item {
padding: 16px 20px; padding: 16px 20px;
border-bottom: 1px solid #21262d; border-bottom: 1px solid var(--border);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@ -174,6 +204,10 @@
border-bottom: none; border-bottom: none;
} }
.list-item:hover {
background: var(--bg-tertiary);
}
.item-left { .item-left {
display: flex; display: flex;
align-items: center; align-items: center;
@ -183,36 +217,19 @@
.symbol { .symbol {
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: #c9d1d9; color: var(--text-primary);
min-width: 100px; min-width: 100px;
} }
.side-badge {
padding: 4px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
}
.side-long {
background: #238636;
color: #3fb950;
}
.side-short {
background: #8b3c3c;
color: #f85149;
}
.item-details { .item-details {
display: flex; display: flex;
gap: 20px; gap: 20px;
font-size: 13px; font-size: 13px;
color: #8b949e; color: var(--text-secondary);
} }
.item-detail span { .item-detail span {
color: #c9d1d9; color: var(--text-primary);
} }
.item-right { .item-right {
@ -225,18 +242,59 @@
} }
.pnl.positive { .pnl.positive {
color: #3fb950; color: var(--accent);
} }
.pnl.negative { .pnl.negative {
color: #f85149; color: #ef4444;
}
/* 方向标签 */
.side-badge {
display: inline-block;
padding: 4px 8px;
border-radius: 2px;
font-size: 12px;
}
.side-badge.long {
background: rgba(0, 255, 65, 0.1);
color: #00ff41;
}
.side-badge.short {
background: rgba(255, 68, 68, 0.1);
color: #ff4444;
}
/* 订单类型标签 */
.order-type-badge {
padding: 2px 8px;
border-radius: 2px;
font-size: 10px;
font-weight: 600;
}
.order-entry {
background: rgba(59, 130, 246, 0.1);
color: #3b82f6;
}
.order-tp {
background: rgba(0, 255, 65, 0.1);
color: #00ff41;
}
.order-sl {
background: rgba(255, 68, 68, 0.1);
color: #ff4444;
} }
/* 空状态 */ /* 空状态 */
.empty-state { .empty-state {
padding: 60px 20px; padding: 60px 20px;
text-align: center; text-align: center;
color: #6e7681; color: var(--text-secondary);
} }
.empty-icon { .empty-icon {
@ -248,34 +306,63 @@
/* 操作按钮 */ /* 操作按钮 */
.action-btn { .action-btn {
padding: 6px 12px; padding: 6px 12px;
background: #21262d; background: transparent;
border: 1px solid #30363d; border: 1px solid var(--border);
color: #c9d1d9; color: var(--text-primary);
border-radius: 6px; border-radius: 4px;
font-size: 12px; font-size: 12px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s;
} }
.action-btn:hover { .action-btn:hover {
background: #30363d; background: var(--bg-tertiary);
border-color: var(--text-secondary);
} }
.action-btn.danger { .action-btn.danger {
border-color: #f85149; border-color: #ef4444;
color: #f85149; color: #ef4444;
} }
.action-btn.danger:hover { .action-btn.danger:hover {
background: #f85149; background: rgba(239, 68, 68, 0.1);
color: white; }
/* 加载动画 */
@keyframes spin {
to { transform: rotate(360deg); }
}
.spinner {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid var(--border);
border-top-color: var(--accent);
border-radius: 50%;
animation: spin 0.6s linear infinite;
}
/* 订单分类标题 */
.order-section-title {
padding: 12px 20px;
font-size: 12px;
color: var(--text-secondary);
background: var(--bg-primary);
border-top: 1px solid var(--border);
border-bottom: 1px solid var(--border);
}
.order-section-title:first-child {
border-top: none;
} }
/* 响应式 */ /* 响应式 */
@media (max-width: 768px) { @media (max-width: 768px) {
.stats-grid { .stats-grid {
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(3, 1fr);
gap: 12px; gap: 8px;
} }
.content-grid { .content-grid {
@ -284,7 +371,11 @@
} }
.stat-value { .stat-value {
font-size: 20px; font-size: 16px;
}
.stat-label {
font-size: 10px;
} }
.symbol { .symbol {
@ -298,81 +389,15 @@
font-size: 11px; font-size: 11px;
} }
} }
/* 加载动画 */
@keyframes spin {
to { transform: rotate(360deg); }
}
.spinner {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid #30363d;
border-top-color: #58a6ff;
border-radius: 50%;
animation: spin 0.6s linear infinite;
}
/* 订单类型标签 */
.order-type-badge {
padding: 2px 8px;
border-radius: 4px;
font-size: 10px;
font-weight: 600;
}
.order-entry {
background: #1f6feb;
color: #58a6ff;
}
.order-tp {
background: #238636;
color: #3fb950;
}
.order-sl {
background: #8b3c3c;
color: #f85149;
}
/* 风险指标 */
.risk-indicator {
display: flex;
align-items: center;
gap: 8px;
}
.risk-bar {
flex: 1;
height: 4px;
background: #21262d;
border-radius: 2px;
overflow: hidden;
}
.risk-fill {
height: 100%;
background: #58a6ff;
transition: width 0.3s ease;
}
.risk-fill.warning {
background: #d29922;
}
.risk-fill.danger {
background: #f85149;
}
</style> </style>
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<div class="container"> <div class="trading-page">
<div class="trading-container">
<!-- 头部 --> <!-- 头部 -->
<div class="header"> <div class="trading-header">
<div class="title">🔥 Hyperliquid 交易监控</div> <div class="trading-title">🔥 Hyperliquid 交易监控</div>
<div style="display: flex; align-items: center; gap: 12px;"> <div style="display: flex; align-items: center; gap: 12px;">
<span class="status-badge" :class="enabled ? 'status-enabled' : 'status-disabled'"> <span class="status-badge" :class="enabled ? 'status-enabled' : 'status-disabled'">
{{ enabled ? '已启用' : '未启用' }} {{ enabled ? '已启用' : '未启用' }}
@ -414,7 +439,7 @@
</div> </div>
<div class="stat-sub"> <div class="stat-sub">
上限: {{ account.max_leverage }}x 上限: {{ account.max_leverage }}x
<span v-if="leverageUtilization > 80" style="color: #d29922; margin-left: 8px;"> <span v-if="leverageUtilization > 80" style="color: #f59e0b; margin-left: 8px;">
⚠️ ⚠️
</span> </span>
</div> </div>
@ -460,7 +485,7 @@
<div class="item-left"> <div class="item-left">
<div> <div>
<div class="symbol">{{ pos.symbol }}</div> <div class="symbol">{{ pos.symbol }}</div>
<span class="side-badge" :class="pos.side === 'long' ? 'side-long' : 'side-short'"> <span class="side-badge" :class="pos.side === 'long' ? 'long' : 'short'">
{{ pos.side === 'long' ? '做多' : '做空' }} {{ pos.side === 'long' ? '做多' : '做空' }}
</span> </span>
</div> </div>
@ -480,7 +505,7 @@
<div class="pnl" :class="getPnLClass(pos.unrealized_pnl)"> <div class="pnl" :class="getPnLClass(pos.unrealized_pnl)">
{{ pos.unrealized_pnl >= 0 ? '+' : '' }}${{ formatNumber(pos.unrealized_pnl) }} {{ pos.unrealized_pnl >= 0 ? '+' : '' }}${{ formatNumber(pos.unrealized_pnl) }}
</div> </div>
<div style="font-size: 11px; color: #8b949e; margin-top: 4px;"> <div style="font-size: 11px; color: var(--text-secondary); margin-top: 4px;">
TP: ${{ formatNumber(pos.take_profit) }} | SL: ${{ formatNumber(pos.stop_loss) }} TP: ${{ formatNumber(pos.take_profit) }} | SL: ${{ formatNumber(pos.stop_loss) }}
</div> </div>
<button class="action-btn danger" @click="closePosition(pos.symbol)" style="margin-top: 8px;"> <button class="action-btn danger" @click="closePosition(pos.symbol)" style="margin-top: 8px;">
@ -505,7 +530,7 @@
<div v-else> <div v-else>
<!-- 入场单 --> <!-- 入场单 -->
<div v-if="entryOrdersList.length > 0"> <div v-if="entryOrdersList.length > 0">
<div style="padding: 12px 20px; font-size: 12px; color: #8b949e; background: #0d1117;"> <div class="order-section-title">
入场单 ({{ entryOrdersList.length }}) 入场单 ({{ entryOrdersList.length }})
</div> </div>
<div v-for="order in entryOrdersList" :key="order.order_id" class="list-item"> <div v-for="order in entryOrdersList" :key="order.order_id" class="list-item">
@ -533,7 +558,7 @@
<!-- 止盈止损单 --> <!-- 止盈止损单 -->
<div v-if="tpSlOrdersList.length > 0"> <div v-if="tpSlOrdersList.length > 0">
<div style="padding: 12px 20px; font-size: 12px; color: #8b949e; background: #0d1117; border-top: 1px solid #30363d;"> <div class="order-section-title">
止盈止损 ({{ tpSlOrdersList.length }}) 止盈止损 ({{ tpSlOrdersList.length }})
</div> </div>
<div v-for="order in tpSlOrdersList" :key="order.order_id" class="list-item"> <div v-for="order in tpSlOrdersList" :key="order.order_id" class="list-item">
@ -541,8 +566,8 @@
<div class="symbol">{{ order.symbol }}</div> <div class="symbol">{{ order.symbol }}</div>
<div class="item-details"> <div class="item-details">
<div class="item-detail"> <div class="item-detail">
<span class="order-type-badge order-tp">TP</span> <span class="order-type-badge order-tp" v-if="order.is_tp">TP</span>
<span class="order-type-badge order-sl">SL</span> <span class="order-type-badge order-sl" v-if="order.is_sl">SL</span>
</div> </div>
<div class="item-detail"> <div class="item-detail">
@ ${{ formatNumber(order.price) }} @ ${{ formatNumber(order.price) }}
@ -553,7 +578,8 @@
</div> </div>
</div> </div>
<div class="item-right"> <div class="item-right">
<span style="font-size: 11px; color: #8b949e;">自动执行</span> <span style="font-size: 11px; color: var(--text-secondary);">自动执行</span>
</div>
</div> </div>
</div> </div>
</div> </div>