From 693a2306cabcf1724eecf9c5c71609fb2fad80b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Wed, 25 Feb 2026 09:49:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(strategy=5Foverview):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E6=89=A7=E8=A1=8C=E6=A6=82=E8=A7=88=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=E4=B8=8E=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在后端API中增强了对策略执行概览的错误处理逻辑,确保在无法加载策略执行数据时提供明确的提示信息。前端组件更新以显示相应的错误信息,提升用户体验并指导用户进行后续操作。此改动增强了系统的可用性与用户友好性。 --- backend/api/routes/system.py | 16 +++++++++-- frontend/src/components/GlobalConfig.jsx | 34 ++++++++++++++---------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/backend/api/routes/system.py b/backend/api/routes/system.py index 765b777..402fcfa 100644 --- a/backend/api/routes/system.py +++ b/backend/api/routes/system.py @@ -1300,20 +1300,32 @@ async def market_overview(_admin: Dict[str, Any] = Depends(require_system_admin) data["beta_filter_triggered"] = triggered # 策略执行概览:当前执行方案与配置项执行情况(易读文字) + get_strategy_execution_overview = None try: from market_overview import get_strategy_execution_overview except ImportError: try: from backend.market_overview import get_strategy_execution_overview except ImportError: - get_strategy_execution_overview = None + pass + if get_strategy_execution_overview is None: + try: + import sys + backend_dir = Path(__file__).resolve().parent.parent.parent + if str(backend_dir) not in sys.path: + sys.path.insert(0, str(backend_dir)) + from market_overview import get_strategy_execution_overview + except ImportError: + pass if get_strategy_execution_overview is not None: try: data["strategy_execution_overview"] = get_strategy_execution_overview() except Exception as e: data["strategy_execution_overview"] = {"sections": [{"title": "加载失败", "content": str(e)}]} else: - data["strategy_execution_overview"] = {"sections": []} + data["strategy_execution_overview"] = { + "sections": [{"title": "策略执行概览暂不可用", "content": "请确认后端已重启并已部署最新代码;若已重启仍无数据,请检查 backend/market_overview.py 与 config_manager 是否可正常导入。"}] + } return data diff --git a/frontend/src/components/GlobalConfig.jsx b/frontend/src/components/GlobalConfig.jsx index 71c06d1..03d706c 100644 --- a/frontend/src/components/GlobalConfig.jsx +++ b/frontend/src/components/GlobalConfig.jsx @@ -1303,21 +1303,27 @@ const GlobalConfig = () => { - {/* 策略执行概览:当前执行方案与配置项执行情况(易读文字) */} - {marketOverview.strategy_execution_overview?.sections?.length > 0 && ( -
-

策略执行概览

-

- 以下为当前生效的整体策略执行标准与机制说明(由数据库/Redis 配置生成,刷新市场行情时一并更新)。 + {/* 策略执行概览:当前执行方案与配置项执行情况(易读文字),有数据则展示,无数据也显示区块并提示 */} +

+

策略执行概览

+ {marketOverview.strategy_execution_overview?.sections?.length > 0 ? ( + <> +

+ 以下为当前生效的整体策略执行标准与机制说明(由数据库/Redis 配置生成,刷新市场行情时一并更新)。 +

+ {marketOverview.strategy_execution_overview.sections.map((sec, idx) => ( +
+
{sec.title}
+
{sec.content}
+
+ ))} + + ) : ( +

+ 暂无数据。请点击上方「刷新」重试;若仍无内容,请确认后端已重启并已部署包含策略执行概览的最新代码。

- {marketOverview.strategy_execution_overview.sections.map((sec, idx) => ( -
-
{sec.title}
-
{sec.content}
-
- ))} -
- )} + )} +
) : (
加载中或拉取失败,请点击刷新