in packages/build-plugin-lowcode/src/utils/index.js [142:192]
function reviewer(key, value) {
if (!value) {
return value;
}
if (key === 'icon') {
if (typeof value === 'object') {
return {
type: 'smile',
size: 'small',
};
}
}
if (typeof value === 'object') {
if (value.type === 'JSFunction') {
let _value = value.value && value.value.trim();
let template = `
return function lowcode() {
const self = this;
try {
return (${_value}).apply(self, arguments);
} catch(e) {
console.log('call function which parsed by lowcode for key ${key} failed: ', e);
return e.message;
}
};`;
try {
return Function(template)();
} catch (e) {
if (e && e.message.includes("Unexpected token '{'")) {
console.log('method need add funtion prefix');
_value = `function ${_value}`;
template = `
return function lowcode() {
const self = this;
try {
return (${_value}).apply(self, arguments);
} catch(e) {
console.log('call function which parsed by lowcode for key ${key} failed: ', e);
return e.message;
}
};`;
return Function(template)();
}
console.error('parse lowcode function error: ', e);
console.error(value);
return value;
}
}
}
return value;
}