diff --git a/packages/utils/src/schema.ts b/packages/utils/src/schema.ts index dfb487583..1580003d2 100644 --- a/packages/utils/src/schema.ts +++ b/packages/utils/src/schema.ts @@ -2,6 +2,15 @@ import { isJSBlock, isJSSlot, ActivityType, NodeSchema, PageSchema, RootSchema } import { isVariable } from './misc'; 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 等标准协议的结构 * @param props @@ -40,6 +49,19 @@ export function compatibleLegaoSchema(props: any): any { 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 = {}; Object.keys(props).forEach((key) => { if (/^__slot__/.test(key) && props[key] === true) {