fix(strategy_overview): 优化策略执行概览的错误处理与提示信息
在后端API中增强了对策略执行概览的错误处理逻辑,确保在无法加载策略执行数据时提供明确的提示信息。前端组件更新以显示相应的错误信息,提升用户体验并指导用户进行后续操作。此改动增强了系统的可用性与用户友好性。
This commit is contained in:
parent
41e53755ea
commit
693a2306ca
|
|
@ -1300,20 +1300,32 @@ async def market_overview(_admin: Dict[str, Any] = Depends(require_system_admin)
|
||||||
data["beta_filter_triggered"] = triggered
|
data["beta_filter_triggered"] = triggered
|
||||||
|
|
||||||
# 策略执行概览:当前执行方案与配置项执行情况(易读文字)
|
# 策略执行概览:当前执行方案与配置项执行情况(易读文字)
|
||||||
|
get_strategy_execution_overview = None
|
||||||
try:
|
try:
|
||||||
from market_overview import get_strategy_execution_overview
|
from market_overview import get_strategy_execution_overview
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from backend.market_overview import get_strategy_execution_overview
|
from backend.market_overview import get_strategy_execution_overview
|
||||||
except ImportError:
|
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:
|
if get_strategy_execution_overview is not None:
|
||||||
try:
|
try:
|
||||||
data["strategy_execution_overview"] = get_strategy_execution_overview()
|
data["strategy_execution_overview"] = get_strategy_execution_overview()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
data["strategy_execution_overview"] = {"sections": [{"title": "加载失败", "content": str(e)}]}
|
data["strategy_execution_overview"] = {"sections": [{"title": "加载失败", "content": str(e)}]}
|
||||||
else:
|
else:
|
||||||
data["strategy_execution_overview"] = {"sections": []}
|
data["strategy_execution_overview"] = {
|
||||||
|
"sections": [{"title": "策略执行概览暂不可用", "content": "请确认后端已重启并已部署最新代码;若已重启仍无数据,请检查 backend/market_overview.py 与 config_manager 是否可正常导入。"}]
|
||||||
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1303,10 +1303,11 @@ const GlobalConfig = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 策略执行概览:当前执行方案与配置项执行情况(易读文字) */}
|
{/* 策略执行概览:当前执行方案与配置项执行情况(易读文字),有数据则展示,无数据也显示区块并提示 */}
|
||||||
{marketOverview.strategy_execution_overview?.sections?.length > 0 && (
|
|
||||||
<div className="strategy-execution-overview" style={{ marginTop: '20px', padding: '16px', background: '#fafafa', borderRadius: '8px', border: '1px solid #eee' }}>
|
<div className="strategy-execution-overview" style={{ marginTop: '20px', padding: '16px', background: '#fafafa', borderRadius: '8px', border: '1px solid #eee' }}>
|
||||||
<h4 style={{ margin: '0 0 12px 0', fontSize: '15px', fontWeight: 600, color: '#333' }}>策略执行概览</h4>
|
<h4 style={{ margin: '0 0 12px 0', fontSize: '15px', fontWeight: 600, color: '#333' }}>策略执行概览</h4>
|
||||||
|
{marketOverview.strategy_execution_overview?.sections?.length > 0 ? (
|
||||||
|
<>
|
||||||
<p style={{ margin: '0 0 14px 0', fontSize: '13px', color: '#666', lineHeight: 1.5 }}>
|
<p style={{ margin: '0 0 14px 0', fontSize: '13px', color: '#666', lineHeight: 1.5 }}>
|
||||||
以下为当前生效的整体策略执行标准与机制说明(由数据库/Redis 配置生成,刷新市场行情时一并更新)。
|
以下为当前生效的整体策略执行标准与机制说明(由数据库/Redis 配置生成,刷新市场行情时一并更新)。
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -1316,8 +1317,13 @@ const GlobalConfig = () => {
|
||||||
<div style={{ fontSize: '13px', color: '#444', lineHeight: 1.6, whiteSpace: 'pre-wrap' }}>{sec.content}</div>
|
<div style={{ fontSize: '13px', color: '#444', lineHeight: 1.6, whiteSpace: 'pre-wrap' }}>{sec.content}</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</>
|
||||||
|
) : (
|
||||||
|
<p style={{ margin: 0, fontSize: '13px', color: '#888' }}>
|
||||||
|
暂无数据。请点击上方「刷新」重试;若仍无内容,请确认后端已重启并已部署包含策略执行概览的最新代码。
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div style={{ color: '#888', fontSize: '14px' }}>加载中或拉取失败,请点击刷新</div>
|
<div style={{ color: '#888', fontSize: '14px' }}>加载中或拉取失败,请点击刷新</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user