(props: any)
| 18 | * @returns |
| 19 | */ |
| 20 | export function compatibleLegaoSchema(props: any): any { |
| 21 | if (!props) { |
| 22 | return props; |
| 23 | } |
| 24 | |
| 25 | if (Array.isArray(props)) { |
| 26 | return props.map(k => compatibleLegaoSchema(k)); |
| 27 | } |
| 28 | |
| 29 | if (!isPlainObject(props)) { |
| 30 | return props; |
| 31 | } |
| 32 | |
| 33 | if (isJSBlock(props)) { |
| 34 | if (props.value.componentName === 'Slot') { |
| 35 | return { |
| 36 | type: 'JSSlot', |
| 37 | title: (props.value.props as any)?.slotTitle, |
| 38 | name: (props.value.props as any)?.slotName, |
| 39 | value: compatibleLegaoSchema(props.value.children), |
| 40 | params: (props.value.props as any)?.slotParams, |
| 41 | }; |
| 42 | } else { |
| 43 | return props.value; |
| 44 | } |
| 45 | } |
| 46 | if (isVariable(props)) { |
| 47 | return { |
| 48 | type: 'JSExpression', |
| 49 | value: props.variable, |
| 50 | mock: props.value, |
| 51 | }; |
| 52 | } |
| 53 | if (isJsObject(props)) { |
| 54 | return { |
| 55 | type: 'JSExpression', |
| 56 | value: props.compiled, |
| 57 | extType: 'function', |
| 58 | }; |
| 59 | } |
| 60 | if (isActionRef(props)) { |
| 61 | return { |
| 62 | type: 'JSExpression', |
| 63 | value: `${props.id}.bind(this)`, |
| 64 | }; |
| 65 | } |
| 66 | const newProps: any = {}; |
| 67 | Object.keys(props).forEach((key) => { |
| 68 | if (/^__slot__/.test(key) && props[key] === true) { |
| 69 | return; |
| 70 | } |
| 71 | // TODO: 先移除,目前没有业务使用 |
| 72 | // if (key === 'dataSource') { |
| 73 | // newProps[key] = props[key]; |
| 74 | // return; |
| 75 | // } |
| 76 | newProps[key] = compatibleLegaoSchema(props[key]); |
| 77 | }); |
no test coverage detected
searching dependent graphs…