fix: lowcode component exec lifecycle has error

This commit is contained in:
liujuping 2022-05-06 15:09:37 +08:00 committed by LeoYuan 袁力皓
parent 9d51dcdae3
commit f99a47e502

View File

@ -2,6 +2,15 @@ import { isJSBlock, isJSSlot, ActivityType, NodeSchema, PageSchema, RootSchema }
import { isVariable } from './misc'; import { isVariable } from './misc';
import { isPlainObject } from './is-plain-object'; import { isPlainObject } from './is-plain-object';
function isJsObject(props: any) {
if (typeof props === 'object' && props !== null) {
return props.type && props.source && props.compiled;
}
}
function isActionRef(props: any): boolean {
return props.type && props.type === 'actionRef';
}
/** /**
* JSExpression / JSSlot * JSExpression / JSSlot
* @param props * @param props
@ -40,6 +49,19 @@ export function compatibleLegaoSchema(props: any): any {
mock: props.value, mock: props.value,
}; };
} }
if (isJsObject(props)) {
return {
type: 'JSExpression',
value: props.compiled,
extType: 'function',
};
}
if (isActionRef(props)) {
return {
type: 'JSExpression',
value: `${props.id}.bind(this)`,
};
}
const newProps: any = {}; const newProps: any = {};
Object.keys(props).forEach((key) => { Object.keys(props).forEach((key) => {
if (/^__slot__/.test(key) && props[key] === true) { if (/^__slot__/.test(key) && props[key] === true) {