|
@@ -2,7 +2,6 @@ import _ from 'lodash'
|
|
|
import {Lib, lookupScope} from './lib'
|
|
|
import {ajax} from "./config";
|
|
|
import {msg as msgSimple, showErrorDialog as showErrorDialogSimple} from "../message";
|
|
|
-import {evalFunction} from "./systemLibEval";
|
|
|
|
|
|
export const SIMPLE_RE = /^(?:\{(?:(\d+)|([a-z_][\w\.]*))\})$/i
|
|
|
|
|
@@ -1145,4 +1144,24 @@ export function msg(content) {
|
|
|
*/
|
|
|
export function showErrorDialog(msg, sender?) {
|
|
|
showErrorDialogSimple(msg, sender)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 用于计算 express 表达式
|
|
|
+ */
|
|
|
+export function evalFunction(data, express) {
|
|
|
+ const keys = []
|
|
|
+ const values = []
|
|
|
+ _.forOwn(data, (value, key) => {
|
|
|
+ keys.push(key)
|
|
|
+ values.push(value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const func = Function(...keys, 'return ' + express)
|
|
|
+
|
|
|
+ try {
|
|
|
+ return func(...values)
|
|
|
+ } catch (e) {
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|