1
This commit is contained in:
parent
20c9333b2f
commit
e97faa9416
@ -3,7 +3,7 @@
|
|||||||
<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">
|
||||||
<title>模拟交易 - Tradus</title>
|
<title>AI 自动交易 - Tradus</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<style>
|
<style>
|
||||||
/* 覆盖全局 #app 样式 */
|
/* 覆盖全局 #app 样式 */
|
||||||
@ -403,6 +403,64 @@
|
|||||||
background: rgba(255, 68, 68, 0.1);
|
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 {
|
.action-btn {
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
@ -501,17 +559,19 @@
|
|||||||
<div class="sticky-header">
|
<div class="sticky-header">
|
||||||
<!-- 头部 -->
|
<!-- 头部 -->
|
||||||
<div class="trading-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 style="display: flex; align-items: center; gap: 12px;">
|
||||||
<div class="monitor-status">
|
<div class="monitor-status">
|
||||||
<div class="monitor-dot" :class="{ running: monitorRunning }"></div>
|
<div class="monitor-dot" :class="{ running: monitorRunning }"></div>
|
||||||
<span>{{ monitorRunning ? '监控中' : '未启动' }}</span>
|
<span>{{ monitorRunning ? '监控中' : '未启动' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<button class="report-btn" @click="sendReport" :disabled="sendingReport">
|
<div class="admin-dropdown">
|
||||||
{{ sendingReport ? '发送中...' : '发送报告' }}
|
<button class="admin-btn" @click="toggleAdminMenu">管理 ▾</button>
|
||||||
</button>
|
<div class="admin-menu" v-if="showAdminMenu">
|
||||||
<button class="refresh-btn" @click="manualRefresh">刷新数据</button>
|
<button @click="adminSendReport">发送报告</button>
|
||||||
<button class="reset-btn" @click="resetData">重置数据</button>
|
<button @click="adminResetData" class="danger">重置数据</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -814,7 +874,9 @@
|
|||||||
latestPrices: {},
|
latestPrices: {},
|
||||||
refreshInterval: null,
|
refreshInterval: null,
|
||||||
isFirstLoad: true,
|
isFirstLoad: true,
|
||||||
sendingReport: false
|
sendingReport: false,
|
||||||
|
showAdminMenu: false,
|
||||||
|
adminPassword: '223388'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -823,17 +885,53 @@
|
|||||||
this.refreshInterval = setInterval(() => {
|
this.refreshInterval = setInterval(() => {
|
||||||
this.silentRefresh();
|
this.silentRefresh();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
// 点击外部关闭菜单
|
||||||
|
document.addEventListener('click', this.closeAdminMenu);
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
if (this.refreshInterval) {
|
if (this.refreshInterval) {
|
||||||
clearInterval(this.refreshInterval);
|
clearInterval(this.refreshInterval);
|
||||||
}
|
}
|
||||||
|
document.removeEventListener('click', this.closeAdminMenu);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 手动刷新(显示 loading)
|
// 切换管理菜单
|
||||||
async manualRefresh() {
|
toggleAdminMenu(event) {
|
||||||
this.loading = true;
|
event.stopPropagation();
|
||||||
await this.refreshData();
|
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)
|
// 静默刷新(不显示 loading)
|
||||||
@ -859,7 +957,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
async resetData() {
|
async resetData() {
|
||||||
if (!confirm('确定要重置所有模拟交易数据吗?\n\n此操作将删除所有订单记录,不可恢复!')) {
|
if (!confirm('确定要重置所有交易数据吗?\n\n此操作将删除所有订单记录,不可恢复!')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,10 +967,10 @@
|
|||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
alert(data.message);
|
alert('数据已重置');
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
} else {
|
} else {
|
||||||
alert('重置失败: ' + (data.detail || '未知错误'));
|
alert('重置失败: ' + data.detail);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert('重置失败: ' + e.message);
|
alert('重置失败: ' + e.message);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user