mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 17:54:15 +08:00
fix(strategy): parsePyValue 对非 JSON 值兜底, 修复 AI 修改 date 参数崩溃 (#124)
get() 对字符串值去外层引号后传给 parsePyValue, 字符串型 default (如 date 类型的 "2024-01-01") 去引号变成 2024-01-01, JSON.parse 在 position 4 报错 → 整个 StrategyBuilderDialog 白屏。 parsePyValue 加 try/catch: JSON.parse 失败时返回原始字符串。 数字/布尔不受影响, 字符串值兜底为字符串。 Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,13 @@ function parsePyValue(v: string): any {
|
||||
if (s === 'True') return true
|
||||
if (s === 'False') return false
|
||||
if (s === 'None') return null
|
||||
return JSON.parse(s)
|
||||
// get() 已对字符串去外层引号, 纯文本值(如 2024-01-01 / anchor_date)
|
||||
// 不是合法 JSON, JSON.parse 会抛错 → 兜底返回原始字符串
|
||||
try {
|
||||
return JSON.parse(s)
|
||||
} catch {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
function slugId(prefix: 'ai' | 'custom' = 'ai'): string {
|
||||
|
||||
Reference in New Issue
Block a user