lu-lowcode-package-form 0.10.1 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,16 @@
1
1
  // 不安全的eval函数,有时间的话需要重新编写公式编译器
2
2
  const evalFormula =(formula) => {
3
3
  let result = "";
4
+ let funcCode = "";
4
5
  try {
5
- result = eval(formula.join(""));
6
+ funcCode =`return ${formula.join("")}`
7
+ // console.log("funcCode",funcCode)
8
+ const func = new Function(funcCode);
9
+ result = func()
10
+ // result = eval(formula.join(""));
6
11
  result = result.toString();
7
12
  } catch (error) {
8
- // console.error("formula error", error);
13
+ console.error(`formula (${funcCode}) error`, error);
9
14
  }
10
15
  // console.log("formula result", result);
11
16
  return result
@@ -13,3 +18,5 @@ const evalFormula =(formula) => {
13
18
 
14
19
  export {evalFormula};
15
20
 
21
+
22
+