Skip to content

Commit f99a47e

Browse files
liujupingLeoYuan
authored andcommitted
fix: lowcode component exec lifecycle has error
1 parent 9d51dcd commit f99a47e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/utils/src/schema.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ import { isJSBlock, isJSSlot, ActivityType, NodeSchema, PageSchema, RootSchema }
22
import { isVariable } from './misc';
33
import { isPlainObject } from './is-plain-object';
44

5+
function isJsObject(props: any) {
6+
if (typeof props === 'object' && props !== null) {
7+
return props.type && props.source && props.compiled;
8+
}
9+
}
10+
function isActionRef(props: any): boolean {
11+
return props.type && props.type === 'actionRef';
12+
}
13+
514
/**
615
* 将「乐高版本」协议升级成 JSExpression / JSSlot 等标准协议的结构
716
* @param props
@@ -40,6 +49,19 @@ export function compatibleLegaoSchema(props: any): any {
4049
mock: props.value,
4150
};
4251
}
52+
if (isJsObject(props)) {
53+
return {
54+
type: 'JSExpression',
55+
value: props.compiled,
56+
extType: 'function',
57+
};
58+
}
59+
if (isActionRef(props)) {
60+
return {
61+
type: 'JSExpression',
62+
value: `${props.id}.bind(this)`,
63+
};
64+
}
4365
const newProps: any = {};
4466
Object.keys(props).forEach((key) => {
4567
if (/^__slot__/.test(key) && props[key] === true) {

0 commit comments

Comments
 (0)