update
This commit is contained in:
parent
e48911d502
commit
ef4b7790cf
@ -3,187 +3,166 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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="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>
|
||||
<style>
|
||||
/* 防止横向滚动 */
|
||||
html, body {
|
||||
overflow-x: hidden;
|
||||
max-width: 100vw;
|
||||
}
|
||||
|
||||
/* 覆盖全局 #app 样式 */
|
||||
#app {
|
||||
height: auto;
|
||||
display: block;
|
||||
align-items: initial;
|
||||
justify-content: initial;
|
||||
padding: 0;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.trading-page {
|
||||
min-height: 100vh;
|
||||
background: var(--bg-primary);
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.trading-container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
.hyperliquid-page {
|
||||
min-height: 100vh;
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
/* 固定顶部区域 */
|
||||
.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 {
|
||||
.paper-badge {
|
||||
display: inline-block;
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
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-weight: 500;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.status-enabled {
|
||||
background: rgba(0, 255, 65, 0.1);
|
||||
color: #00ff41;
|
||||
border: 1px solid rgba(0, 255, 65, 0.3);
|
||||
background: var(--success-light);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.status-disabled {
|
||||
background: rgba(128, 128, 128, 0.1);
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* 统计卡片 */
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap: var(--space-md);
|
||||
margin-bottom: var(--space-xl);
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: var(--bg-secondary);
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
padding: 16px;
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--space-lg);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
border-color: var(--primary);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
font-size: var(--font-sm);
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 6px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin-bottom: var(--space-sm);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 24px;
|
||||
font-weight: 300;
|
||||
color: var(--accent);
|
||||
font-size: var(--font-2xl);
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: var(--space-xs);
|
||||
font-family: 'Inter', monospace;
|
||||
}
|
||||
|
||||
.stat-value.positive {
|
||||
color: var(--accent);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.stat-value.negative {
|
||||
color: #ef4444;
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.stat-value.warning {
|
||||
color: #f59e0b;
|
||||
color: var(--warning);
|
||||
}
|
||||
|
||||
.stat-sub {
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
margin-top: 4px;
|
||||
font-size: var(--font-sm);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
/* 内容区域 */
|
||||
.content-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 24px;
|
||||
margin-bottom: 24px;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--space-lg);
|
||||
}
|
||||
|
||||
/* 面板 */
|
||||
.panel {
|
||||
background: var(--bg-secondary);
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
border-radius: var(--radius-md);
|
||||
overflow: hidden;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.panel:hover {
|
||||
border-color: var(--primary);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 20px;
|
||||
padding: 20px 24px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--bg-primary);
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.panel-title {
|
||||
font-size: 16px;
|
||||
font-size: var(--font-lg);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.panel-count {
|
||||
font-size: 12px;
|
||||
font-size: var(--font-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
@ -191,13 +170,13 @@
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 列表项 */
|
||||
.list-item {
|
||||
padding: 16px 20px;
|
||||
padding: 18px 24px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.list-item:last-child {
|
||||
@ -205,172 +184,148 @@
|
||||
}
|
||||
|
||||
.list-item:hover {
|
||||
background: var(--bg-tertiary);
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.item-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.symbol {
|
||||
font-size: 16px;
|
||||
font-size: var(--font-md);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
min-width: 100px;
|
||||
min-width: 96px;
|
||||
}
|
||||
|
||||
.item-details {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
font-size: 13px;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 20px;
|
||||
font-size: var(--font-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.item-detail span {
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.item-right {
|
||||
text-align: right;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pnl {
|
||||
font-size: 14px;
|
||||
font-size: var(--font-base);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pnl.positive {
|
||||
color: var(--accent);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.pnl.negative {
|
||||
color: #ef4444;
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
/* 方向标签 */
|
||||
.side-badge {
|
||||
display: inline-block;
|
||||
padding: 4px 8px;
|
||||
border-radius: 2px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-top: 8px;
|
||||
padding: 4px 10px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.side-badge.long {
|
||||
background: rgba(0, 255, 65, 0.1);
|
||||
color: #00ff41;
|
||||
background: var(--success-light);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.side-badge.short {
|
||||
background: rgba(255, 68, 68, 0.1);
|
||||
color: #ff4444;
|
||||
background: var(--error-light);
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
/* 订单类型标签 */
|
||||
.order-type-badge {
|
||||
padding: 2px 8px;
|
||||
border-radius: 2px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 3px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.order-entry {
|
||||
background: rgba(59, 130, 246, 0.1);
|
||||
color: #3b82f6;
|
||||
background: var(--info-light);
|
||||
color: var(--info);
|
||||
}
|
||||
|
||||
.order-tp {
|
||||
background: rgba(0, 255, 65, 0.1);
|
||||
color: #00ff41;
|
||||
background: var(--success-light);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.order-sl {
|
||||
background: rgba(255, 68, 68, 0.1);
|
||||
color: #ff4444;
|
||||
background: var(--error-light);
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
/* 钱包地址 */
|
||||
.wallet-link {
|
||||
color: var(--accent);
|
||||
color: var(--primary);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
display: flex;
|
||||
font-weight: 600;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
transition: opacity 0.2s;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.wallet-link:hover {
|
||||
opacity: 0.7;
|
||||
text-decoration: underline;
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
|
||||
.wallet-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state {
|
||||
padding: 60px 20px;
|
||||
padding: 56px 24px;
|
||||
text-align: center;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.empty-state p + p {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 48px;
|
||||
margin-bottom: 16px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* 操作按钮 */
|
||||
.action-btn {
|
||||
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;
|
||||
.subtle-note {
|
||||
font-size: 11px;
|
||||
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-bottom: 1px solid var(--border);
|
||||
}
|
||||
@ -379,67 +334,73 @@
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 768px) {
|
||||
.stats-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.content-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 16px;
|
||||
.header-actions {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 10px;
|
||||
.header-actions .btn {
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.symbol {
|
||||
min-width: 80px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.item-details {
|
||||
.list-item {
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-size: 11px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.item-left,
|
||||
.item-right {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.item-right {
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="trading-page">
|
||||
<div class="trading-container">
|
||||
<!-- 头部 -->
|
||||
<div class="trading-header">
|
||||
<div class="trading-title">🔥 Hyperliquid 交易监控</div>
|
||||
<div style="display: flex; align-items: center; gap: 12px;">
|
||||
<div class="hyperliquid-page">
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<div class="page-title">
|
||||
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'">
|
||||
{{ enabled ? '已启用' : '未启用' }}
|
||||
</span>
|
||||
<button class="refresh-btn" @click="refreshData" :class="{ loading: loading }">
|
||||
<span v-if="loading" class="spinner"></span>
|
||||
<button class="btn btn-secondary" @click="refreshData" :disabled="loading">
|
||||
<span v-if="loading" class="spinner btn-spinner"></span>
|
||||
{{ loading ? '刷新中...' : '刷新' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 未启用提示 -->
|
||||
<div v-if="!enabled" class="empty-state">
|
||||
<div class="empty-icon">🔒</div>
|
||||
<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 v-else>
|
||||
<!-- 账户信息 -->
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">钱包地址</div>
|
||||
@ -500,9 +461,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 持仓和挂单 -->
|
||||
<div class="content-grid">
|
||||
<!-- 持仓列表 -->
|
||||
<div class="panel">
|
||||
<div class="panel-header">
|
||||
<div class="panel-title">📈 持仓 ({{ positions.length }})</div>
|
||||
@ -537,10 +496,10 @@
|
||||
<div class="pnl" :class="getPnLClass(pos.unrealized_pnl)">
|
||||
{{ pos.unrealized_pnl >= 0 ? '+' : '' }}${{ formatNumber(pos.unrealized_pnl) }}
|
||||
</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) }}
|
||||
</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>
|
||||
</div>
|
||||
@ -549,7 +508,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 挂单列表 -->
|
||||
<div class="panel">
|
||||
<div class="panel-header">
|
||||
<div class="panel-title">📋 挂单 ({{ orders.entry_orders + orders.tp_sl_orders }})</div>
|
||||
@ -560,7 +518,6 @@
|
||||
<p>暂无挂单</p>
|
||||
</div>
|
||||
<div v-else>
|
||||
<!-- 入场单 -->
|
||||
<div v-if="entryOrdersList.length > 0">
|
||||
<div class="order-section-title">
|
||||
入场单 ({{ entryOrdersList.length }})
|
||||
@ -581,14 +538,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 止盈止损单 -->
|
||||
<div v-if="tpSlOrdersList.length > 0">
|
||||
<div class="order-section-title">
|
||||
止盈止损 ({{ tpSlOrdersList.length }})
|
||||
@ -610,7 +566,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-right">
|
||||
<span style="font-size: 11px; color: var(--text-secondary);">自动执行</span>
|
||||
<span class="subtle-note">自动执行</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user