优化:避免模块表达式求值错误(例如结果是布尔型),避免面板出错

pull/3078/MERGE
ChenX 4 weeks ago
parent a8a77294d9
commit e4f3005a9a

@ -84,10 +84,13 @@ export function eval2(expr: string, params?: {}, defaultParam?: string): number
let result = eval(code);
if (typeof result === "function")
return result();
result = result();
if (typeof result === "bigint")
return Number(result);//防止bigint乱入
result = Number(result);//防止bigint乱入
if (typeof result !== "number")
throw "计算结果不是实数!";
return result;
}

@ -706,7 +706,7 @@ export class TemplateParamDetail extends React.Component<{}>
}}
title={par.name}
>{par.name}</span>
<span>{FixedNotZero(par.value, 2)}</span>
<span>{typeof par.value === "number" ? FixedNotZero(par.value, 2) : par.value}</span>
<span style={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", padding: "0 2px" }} title={par.description}>{par.description}</span>
{
par.type === TemplateParamType.Material ?

Loading…
Cancel
Save