From dbcb7012bdf1d47a71e9988f161a9e8f69a256ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Sat, 21 Feb 2026 00:59:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(account,=20frontend):=20=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `account.py` 中更新了创建时间的获取逻辑,兼容 `created_at` 和 `create_at` 字段。前端组件 `StatsDashboard.jsx` 中相应调整了创建时间的展示逻辑,确保在 `created_at` 字段为空时能够正确显示。此更新提升了数据展示的准确性与用户体验。 --- backend/api/routes/account.py | 3 ++- frontend/src/components/StatsDashboard.jsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/api/routes/account.py b/backend/api/routes/account.py index 65979eb..0b18b00 100644 --- a/backend/api/routes/account.py +++ b/backend/api/routes/account.py @@ -766,7 +766,8 @@ async def fetch_realtime_positions(account_id: int): if matched is None: matched = db_trades[0] entry_time = matched.get('entry_time') - created_at = matched.get('created_at') # 创建时间,无 entry_time 时用于展示开仓时间 + # 创建时间:兼容 DB 列名 created_at / create_at + created_at = matched.get('created_at') if matched.get('created_at') is not None else matched.get('create_at') stop_loss_price = matched.get('stop_loss_price') take_profit_price = matched.get('take_profit_price') take_profit_1 = matched.get('take_profit_1') diff --git a/frontend/src/components/StatsDashboard.jsx b/frontend/src/components/StatsDashboard.jsx index d96efce..8f84a6c 100644 --- a/frontend/src/components/StatsDashboard.jsx +++ b/frontend/src/components/StatsDashboard.jsx @@ -742,7 +742,7 @@ const StatsDashboard = () => { 开仓时间: {(trade.entry_time || trade.created_at) ? formatEntryTime(trade.entry_time || trade.created_at) : '—'}
- 创建时间: {trade.created_at ? formatEntryTime(trade.created_at) : '—'} + 创建时间: {(trade.created_at != null && trade.created_at !== '') ? formatEntryTime(trade.created_at) : '—'}