This commit is contained in:
aaron 2026-02-23 00:30:45 +08:00
parent 1de64df2dc
commit a83000075c

View File

@ -457,20 +457,20 @@
<button <button
class="tab" class="tab"
:class="{ active: currentTab === 'positions' }" :class="{ active: currentTab === 'positions' }"
@click="currentTab = 'positions'"> @click="switchTab('positions')">
交易所持仓 ({{ exchangePositions.length }}) 交易所持仓 ({{ exchangePositions.length }})
</button> </button>
<button <button
class="tab" class="tab"
:class="{ active: currentTab === 'trades' }" :class="{ active: currentTab === 'trades' }"
@click="currentTab = 'trades'"> @click="switchTab('trades')">
成交记录 成交记录 ({{ tradeHistory.length }})
</button> </button>
<button <button
class="tab" class="tab"
:class="{ active: currentTab === 'orders' }" :class="{ active: currentTab === 'orders' }"
@click="currentTab = 'orders'"> @click="switchTab('orders')">
历史订单 历史订单 ({{ orderHistory.length }})
</button> </button>
</div> </div>
@ -650,6 +650,23 @@
} }
}, },
methods: { methods: {
async switchTab(tab) {
if (this.currentTab === tab) return; // 已经是当前标签,不重新加载
this.currentTab = tab;
// 切换标签时加载对应数据
this.loading = true;
try {
if (tab === 'trades') {
await this.fetchTradeHistory();
} else if (tab === 'orders') {
await this.fetchOrderHistory();
}
} finally {
this.loading = false;
}
},
async refreshData() { async refreshData() {
this.loading = true; this.loading = true;
try { try {