This commit is contained in:
aaron 2026-03-29 22:18:38 +08:00
parent e48911d502
commit ef4b7790cf

View File

@ -3,187 +3,166 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Hyperliquid 交易监控 | AI Agent</title> <title>XClaw AI | Hyperliquid</title>
<link rel="stylesheet" href="/static/css/style.css"> <link rel="stylesheet" href="/static/css/style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<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>
/* 防止横向滚动 */
html, body { html, body {
overflow-x: hidden; overflow-x: hidden;
max-width: 100vw; max-width: 100vw;
} }
/* 覆盖全局 #app 样式 */
#app { #app {
height: auto;
display: block;
align-items: initial;
justify-content: initial;
padding: 0;
overflow-x: hidden;
}
.trading-page {
min-height: 100vh; min-height: 100vh;
background: var(--bg-primary);
padding: 20px;
} }
.trading-container { .hyperliquid-page {
max-width: 1400px; min-height: 100vh;
margin: 0 auto; background: var(--bg-secondary);
} }
/* 固定顶部区域 */ .paper-badge {
.sticky-header {
position: sticky;
top: 0;
z-index: 100;
background: var(--bg-primary);
padding-bottom: 10px;
}
.trading-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
padding: 10px 0 20px 0;
border-bottom: 1px solid var(--border);
background: var(--bg-primary);
}
.trading-title {
font-size: 24px;
font-weight: 300;
color: var(--text-primary);
user-select: none;
cursor: default;
}
.trading-title span {
color: var(--accent);
}
.refresh-btn {
padding: 8px 16px;
background: transparent;
border: 1px solid var(--accent);
color: var(--accent);
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
}
.refresh-btn:hover {
background: var(--accent);
color: var(--bg-primary);
}
.refresh-btn.loading {
opacity: 0.6;
cursor: wait;
}
/* 状态标签 */
.status-badge {
display: inline-block; display: inline-block;
background: var(--primary);
color: white;
padding: 4px 12px; padding: 4px 12px;
border-radius: 20px; border-radius: var(--radius-sm);
font-size: 11px;
font-weight: 700;
letter-spacing: 1px;
margin-left: 12px;
}
.header-actions {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.btn[disabled] {
opacity: 0.7;
cursor: not-allowed;
}
.btn-spinner {
width: 14px;
height: 14px;
border-width: 2px;
}
.status-badge {
display: inline-flex;
align-items: center;
padding: 6px 12px;
border-radius: var(--radius-sm);
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 600;
} }
.status-enabled { .status-enabled {
background: rgba(0, 255, 65, 0.1); background: var(--success-light);
color: #00ff41; color: var(--success);
border: 1px solid rgba(0, 255, 65, 0.3);
} }
.status-disabled { .status-disabled {
background: rgba(128, 128, 128, 0.1); background: var(--bg-tertiary);
color: var(--text-secondary); color: var(--text-secondary);
border: 1px solid var(--border);
} }
/* 统计卡片 */
.stats-grid { .stats-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px; gap: var(--space-md);
margin-bottom: 20px; margin-bottom: var(--space-xl);
} }
.stat-card { .stat-card {
background: var(--bg-secondary); background: var(--bg-primary);
border: 1px solid var(--border); border: 1px solid var(--border);
border-radius: 4px; border-radius: var(--radius-md);
padding: 16px; padding: var(--space-lg);
transition: all 0.2s;
}
.stat-card:hover {
border-color: var(--primary);
box-shadow: var(--shadow-md);
} }
.stat-label { .stat-label {
font-size: 12px; font-size: var(--font-sm);
color: var(--text-secondary); color: var(--text-secondary);
margin-bottom: 6px; text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: var(--space-sm);
font-weight: 500;
} }
.stat-value { .stat-value {
font-size: 24px; font-size: var(--font-2xl);
font-weight: 300; font-weight: 700;
color: var(--accent); color: var(--text-primary);
margin-bottom: var(--space-xs);
font-family: 'Inter', monospace;
} }
.stat-value.positive { .stat-value.positive {
color: var(--accent); color: var(--success);
} }
.stat-value.negative { .stat-value.negative {
color: #ef4444; color: var(--error);
} }
.stat-value.warning { .stat-value.warning {
color: #f59e0b; color: var(--warning);
} }
.stat-sub { .stat-sub {
font-size: 11px; font-size: var(--font-sm);
color: var(--text-secondary); color: var(--text-tertiary);
margin-top: 4px;
} }
/* 内容区域 */
.content-grid { .content-grid {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 24px; gap: var(--space-lg);
margin-bottom: 24px;
} }
/* 面板 */
.panel { .panel {
background: var(--bg-secondary); background: var(--bg-primary);
border: 1px solid var(--border); border: 1px solid var(--border);
border-radius: 4px; border-radius: var(--radius-md);
overflow: hidden; overflow: hidden;
transition: all 0.2s;
}
.panel:hover {
border-color: var(--primary);
box-shadow: var(--shadow-md);
} }
.panel-header { .panel-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 16px 20px; padding: 20px 24px;
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
background: var(--bg-primary); background: var(--bg-secondary);
} }
.panel-title { .panel-title {
font-size: 16px; font-size: var(--font-lg);
font-weight: 600; font-weight: 600;
color: var(--text-primary); color: var(--text-primary);
} }
.panel-count { .panel-count {
font-size: 12px; font-size: var(--font-sm);
color: var(--text-secondary); color: var(--text-secondary);
} }
@ -191,13 +170,13 @@
padding: 0; padding: 0;
} }
/* 列表项 */
.list-item { .list-item {
padding: 16px 20px; padding: 18px 24px;
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: flex-start;
gap: 16px;
} }
.list-item:last-child { .list-item:last-child {
@ -205,172 +184,148 @@
} }
.list-item:hover { .list-item:hover {
background: var(--bg-tertiary); background: var(--bg-secondary);
} }
.item-left { .item-left {
display: flex; display: flex;
align-items: center; align-items: flex-start;
gap: 16px; gap: 16px;
flex: 1;
min-width: 0;
} }
.symbol { .symbol {
font-size: 16px; font-size: var(--font-md);
font-weight: 600; font-weight: 600;
color: var(--text-primary); color: var(--text-primary);
min-width: 100px; min-width: 96px;
} }
.item-details { .item-details {
display: flex; display: flex;
gap: 20px; flex-wrap: wrap;
font-size: 13px; gap: 8px 20px;
font-size: var(--font-sm);
color: var(--text-secondary); color: var(--text-secondary);
} }
.item-detail span { .item-detail span {
color: var(--text-primary); color: var(--text-primary);
font-weight: 600;
} }
.item-right { .item-right {
text-align: right; text-align: right;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8px;
} }
.pnl { .pnl {
font-size: 14px; font-size: var(--font-base);
font-weight: 600; font-weight: 600;
} }
.pnl.positive { .pnl.positive {
color: var(--accent); color: var(--success);
} }
.pnl.negative { .pnl.negative {
color: #ef4444; color: var(--error);
} }
/* 方向标签 */
.side-badge { .side-badge {
display: inline-block; display: inline-flex;
padding: 4px 8px; align-items: center;
border-radius: 2px; margin-top: 8px;
padding: 4px 10px;
border-radius: var(--radius-sm);
font-size: 12px; font-size: 12px;
font-weight: 600;
} }
.side-badge.long { .side-badge.long {
background: rgba(0, 255, 65, 0.1); background: var(--success-light);
color: #00ff41; color: var(--success);
} }
.side-badge.short { .side-badge.short {
background: rgba(255, 68, 68, 0.1); background: var(--error-light);
color: #ff4444; color: var(--error);
} }
/* 订单类型标签 */
.order-type-badge { .order-type-badge {
padding: 2px 8px; display: inline-flex;
border-radius: 2px; align-items: center;
padding: 3px 8px;
border-radius: var(--radius-sm);
font-size: 10px; font-size: 10px;
font-weight: 600; font-weight: 600;
} }
.order-entry { .order-entry {
background: rgba(59, 130, 246, 0.1); background: var(--info-light);
color: #3b82f6; color: var(--info);
} }
.order-tp { .order-tp {
background: rgba(0, 255, 65, 0.1); background: var(--success-light);
color: #00ff41; color: var(--success);
} }
.order-sl { .order-sl {
background: rgba(255, 68, 68, 0.1); background: var(--error-light);
color: #ff4444; color: var(--error);
} }
/* 钱包地址 */
.wallet-link { .wallet-link {
color: var(--accent); color: var(--primary);
text-decoration: none; text-decoration: none;
font-size: 14px; font-size: 14px;
font-weight: 500; font-weight: 600;
display: flex; display: inline-flex;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
transition: opacity 0.2s; transition: color 0.2s;
} }
.wallet-link:hover { .wallet-link:hover {
opacity: 0.7; color: var(--primary-dark);
text-decoration: underline;
} }
.wallet-icon { .wallet-icon {
font-size: 16px; font-size: 16px;
} }
/* 空状态 */
.empty-state { .empty-state {
padding: 60px 20px; padding: 56px 24px;
text-align: center; text-align: center;
color: var(--text-secondary); color: var(--text-secondary);
} }
.empty-state p + p {
margin-top: 8px;
}
.empty-icon { .empty-icon {
font-size: 48px; font-size: 48px;
margin-bottom: 16px; margin-bottom: 16px;
opacity: 0.5; opacity: 0.5;
} }
/* 操作按钮 */ .subtle-note {
.action-btn { font-size: 11px;
padding: 6px 12px;
background: transparent;
border: 1px solid var(--border);
color: var(--text-primary);
border-radius: 4px;
font-size: 12px;
cursor: pointer;
transition: all 0.2s;
}
.action-btn:hover {
background: var(--bg-tertiary);
border-color: var(--text-secondary);
}
.action-btn.danger {
border-color: #ef4444;
color: #ef4444;
}
.action-btn.danger:hover {
background: rgba(239, 68, 68, 0.1);
}
/* 加载动画 */
@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); color: var(--text-secondary);
background: var(--bg-primary); }
.order-section-title {
padding: 12px 24px;
font-size: 12px;
font-weight: 600;
color: var(--text-secondary);
background: var(--bg-secondary);
border-top: 1px solid var(--border); border-top: 1px solid var(--border);
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
} }
@ -379,67 +334,73 @@
border-top: none; border-top: none;
} }
/* 响应式 */ @media (max-width: 1024px) {
@media (max-width: 768px) {
.stats-grid {
grid-template-columns: repeat(3, 1fr);
gap: 8px;
}
.content-grid { .content-grid {
grid-template-columns: 1fr; grid-template-columns: 1fr;
gap: 16px; }
}
@media (max-width: 768px) {
.stats-grid {
grid-template-columns: 1fr;
} }
.stat-value { .header-actions {
font-size: 16px; width: 100%;
} }
.stat-label { .header-actions .btn {
font-size: 10px; flex: 1;
justify-content: center;
} }
.symbol { .list-item {
min-width: 80px;
font-size: 14px;
}
.item-details {
flex-direction: column; flex-direction: column;
gap: 4px; align-items: stretch;
font-size: 11px; }
.item-left,
.item-right {
width: 100%;
}
.item-right {
align-items: flex-start;
text-align: left;
} }
} }
</style> </style>
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<div class="trading-page"> <div class="hyperliquid-page">
<div class="trading-container"> <div class="container">
<!-- 头部 --> <div class="page-header">
<div class="trading-header"> <div>
<div class="trading-title">🔥 Hyperliquid 交易监控</div> <div class="page-title">
<div style="display: flex; align-items: center; gap: 12px;"> XClaw
<span class="paper-badge">Hyperliquid</span>
</div>
<div class="page-subtitle">Hyperliquid 实盘账户、持仓与挂单监控面板</div>
</div>
<div class="header-actions">
<span class="status-badge" :class="enabled ? 'status-enabled' : 'status-disabled'"> <span class="status-badge" :class="enabled ? 'status-enabled' : 'status-disabled'">
{{ enabled ? '已启用' : '未启用' }} {{ enabled ? '已启用' : '未启用' }}
</span> </span>
<button class="refresh-btn" @click="refreshData" :class="{ loading: loading }"> <button class="btn btn-secondary" @click="refreshData" :disabled="loading">
<span v-if="loading" class="spinner"></span> <span v-if="loading" class="spinner btn-spinner"></span>
{{ loading ? '刷新中...' : '刷新' }} {{ loading ? '刷新中...' : '刷新' }}
</button> </button>
</div> </div>
</div> </div>
<!-- 未启用提示 -->
<div v-if="!enabled" class="empty-state"> <div v-if="!enabled" class="empty-state">
<div class="empty-icon">🔒</div> <div class="empty-icon">🔒</div>
<p>Hyperliquid 实盘交易未启用</p> <p>Hyperliquid 实盘交易未启用</p>
<p style="font-size: 13px; margin-top: 8px;">请在 .env 文件中设置 hyperliquid_trading_enabled=true</p> <p>请在 <code>.env</code> 文件中设置 <code>hyperliquid_trading_enabled=true</code></p>
</div> </div>
<!-- 已启用内容 -->
<div v-else> <div v-else>
<!-- 账户信息 -->
<div class="stats-grid"> <div class="stats-grid">
<div class="stat-card"> <div class="stat-card">
<div class="stat-label">钱包地址</div> <div class="stat-label">钱包地址</div>
@ -500,9 +461,7 @@
</div> </div>
</div> </div>
<!-- 持仓和挂单 -->
<div class="content-grid"> <div class="content-grid">
<!-- 持仓列表 -->
<div class="panel"> <div class="panel">
<div class="panel-header"> <div class="panel-header">
<div class="panel-title">📈 持仓 ({{ positions.length }})</div> <div class="panel-title">📈 持仓 ({{ positions.length }})</div>
@ -537,10 +496,10 @@
<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: var(--text-secondary); margin-top: 4px;"> <div class="subtle-note">
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="btn btn-danger btn-small" @click="closePosition(pos.symbol)">
平仓 平仓
</button> </button>
</div> </div>
@ -549,7 +508,6 @@
</div> </div>
</div> </div>
<!-- 挂单列表 -->
<div class="panel"> <div class="panel">
<div class="panel-header"> <div class="panel-header">
<div class="panel-title">📋 挂单 ({{ orders.entry_orders + orders.tp_sl_orders }})</div> <div class="panel-title">📋 挂单 ({{ orders.entry_orders + orders.tp_sl_orders }})</div>
@ -560,7 +518,6 @@
<p>暂无挂单</p> <p>暂无挂单</p>
</div> </div>
<div v-else> <div v-else>
<!-- 入场单 -->
<div v-if="entryOrdersList.length > 0"> <div v-if="entryOrdersList.length > 0">
<div class="order-section-title"> <div class="order-section-title">
入场单 ({{ entryOrdersList.length }}) 入场单 ({{ entryOrdersList.length }})
@ -581,14 +538,13 @@
</div> </div>
</div> </div>
<div class="item-right"> <div class="item-right">
<button class="action-btn danger" @click="cancelOrder(order.symbol)"> <button class="btn btn-danger btn-small" @click="cancelOrder(order.symbol)">
取消 取消
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<!-- 止盈止损单 -->
<div v-if="tpSlOrdersList.length > 0"> <div v-if="tpSlOrdersList.length > 0">
<div class="order-section-title"> <div class="order-section-title">
止盈止损 ({{ tpSlOrdersList.length }}) 止盈止损 ({{ tpSlOrdersList.length }})
@ -610,7 +566,7 @@
</div> </div>
</div> </div>
<div class="item-right"> <div class="item-right">
<span style="font-size: 11px; color: var(--text-secondary);">自动执行</span> <span class="subtle-note">自动执行</span>
</div> </div>
</div> </div>
</div> </div>