1
This commit is contained in:
parent
20c9333b2f
commit
e97faa9416
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>模拟交易 - Tradus</title>
|
||||
<title>AI 自动交易 - Tradus</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<style>
|
||||
/* 覆盖全局 #app 样式 */
|
||||
@ -403,6 +403,64 @@
|
||||
background: rgba(255, 68, 68, 0.1);
|
||||
}
|
||||
|
||||
/* 管理下拉菜单 */
|
||||
.admin-dropdown {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.admin-btn {
|
||||
padding: 8px 16px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border-bright);
|
||||
color: var(--text-secondary);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.admin-btn:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.admin-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 4px;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
min-width: 120px;
|
||||
z-index: 1000;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.admin-menu button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 10px 16px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 14px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.admin-menu button:hover {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.admin-menu button.danger {
|
||||
color: #ff4444;
|
||||
}
|
||||
|
||||
.admin-menu button.danger:hover {
|
||||
background: rgba(255, 68, 68, 0.1);
|
||||
}
|
||||
|
||||
/* 操作按钮 */
|
||||
.action-btn {
|
||||
padding: 4px 8px;
|
||||
@ -501,17 +559,19 @@
|
||||
<div class="sticky-header">
|
||||
<!-- 头部 -->
|
||||
<div class="trading-header">
|
||||
<h1 class="trading-title">模拟交易 <span>Paper Trading</span></h1>
|
||||
<h1 class="trading-title">AI 自动交易 <span>Auto Trading</span></h1>
|
||||
<div style="display: flex; align-items: center; gap: 12px;">
|
||||
<div class="monitor-status">
|
||||
<div class="monitor-dot" :class="{ running: monitorRunning }"></div>
|
||||
<span>{{ monitorRunning ? '监控中' : '未启动' }}</span>
|
||||
</div>
|
||||
<button class="report-btn" @click="sendReport" :disabled="sendingReport">
|
||||
{{ sendingReport ? '发送中...' : '发送报告' }}
|
||||
</button>
|
||||
<button class="refresh-btn" @click="manualRefresh">刷新数据</button>
|
||||
<button class="reset-btn" @click="resetData">重置数据</button>
|
||||
<div class="admin-dropdown">
|
||||
<button class="admin-btn" @click="toggleAdminMenu">管理 ▾</button>
|
||||
<div class="admin-menu" v-if="showAdminMenu">
|
||||
<button @click="adminSendReport">发送报告</button>
|
||||
<button @click="adminResetData" class="danger">重置数据</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -814,7 +874,9 @@
|
||||
latestPrices: {},
|
||||
refreshInterval: null,
|
||||
isFirstLoad: true,
|
||||
sendingReport: false
|
||||
sendingReport: false,
|
||||
showAdminMenu: false,
|
||||
adminPassword: '223388'
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@ -823,17 +885,53 @@
|
||||
this.refreshInterval = setInterval(() => {
|
||||
this.silentRefresh();
|
||||
}, 3000);
|
||||
// 点击外部关闭菜单
|
||||
document.addEventListener('click', this.closeAdminMenu);
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (this.refreshInterval) {
|
||||
clearInterval(this.refreshInterval);
|
||||
}
|
||||
document.removeEventListener('click', this.closeAdminMenu);
|
||||
},
|
||||
methods: {
|
||||
// 手动刷新(显示 loading)
|
||||
async manualRefresh() {
|
||||
this.loading = true;
|
||||
await this.refreshData();
|
||||
// 切换管理菜单
|
||||
toggleAdminMenu(event) {
|
||||
event.stopPropagation();
|
||||
this.showAdminMenu = !this.showAdminMenu;
|
||||
},
|
||||
|
||||
// 关闭管理菜单
|
||||
closeAdminMenu(event) {
|
||||
if (!event.target.closest('.admin-dropdown')) {
|
||||
this.showAdminMenu = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 验证管理密码
|
||||
verifyAdminPassword() {
|
||||
const password = prompt('请输入管理密码:');
|
||||
return password === this.adminPassword;
|
||||
},
|
||||
|
||||
// 管理操作:发送报告
|
||||
async adminSendReport() {
|
||||
this.showAdminMenu = false;
|
||||
if (!this.verifyAdminPassword()) {
|
||||
alert('密码错误');
|
||||
return;
|
||||
}
|
||||
await this.sendReport();
|
||||
},
|
||||
|
||||
// 管理操作:重置数据
|
||||
async adminResetData() {
|
||||
this.showAdminMenu = false;
|
||||
if (!this.verifyAdminPassword()) {
|
||||
alert('密码错误');
|
||||
return;
|
||||
}
|
||||
await this.resetData();
|
||||
},
|
||||
|
||||
// 静默刷新(不显示 loading)
|
||||
@ -859,7 +957,7 @@
|
||||
},
|
||||
|
||||
async resetData() {
|
||||
if (!confirm('确定要重置所有模拟交易数据吗?\n\n此操作将删除所有订单记录,不可恢复!')) {
|
||||
if (!confirm('确定要重置所有交易数据吗?\n\n此操作将删除所有订单记录,不可恢复!')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -869,10 +967,10 @@
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
alert(data.message);
|
||||
alert('数据已重置');
|
||||
this.refreshData();
|
||||
} else {
|
||||
alert('重置失败: ' + (data.detail || '未知错误'));
|
||||
alert('重置失败: ' + data.detail);
|
||||
}
|
||||
} catch (e) {
|
||||
alert('重置失败: ' + e.message);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user