diff --git a/packages/vision-polyfill/src/props-reducers/downgrade-schema-reducer.ts b/packages/vision-polyfill/src/props-reducers/downgrade-schema-reducer.ts index 9efe913cf..b727ecee6 100644 --- a/packages/vision-polyfill/src/props-reducers/downgrade-schema-reducer.ts +++ b/packages/vision-polyfill/src/props-reducers/downgrade-schema-reducer.ts @@ -9,12 +9,9 @@ export function compatibleReducer(props: any, node: Node): any { if (!node.componentMeta.prototype) { return props; } - if (!props || !(isPlainObject(props) || Array.isArray(props))) { + if (!props || !isPlainObject(props)) { return props; } - if (Array.isArray(props)) { - return props.map(k => compatibleReducer(k, node)); - } // 为了能降级到老版本,建议在后期版本去掉以下代码 if (isJSSlot(props)) { return { diff --git a/packages/vision-polyfill/src/props-reducers/upgrade-reducer.ts b/packages/vision-polyfill/src/props-reducers/upgrade-reducer.ts index 61f8d17e7..7fb8939c8 100644 --- a/packages/vision-polyfill/src/props-reducers/upgrade-reducer.ts +++ b/packages/vision-polyfill/src/props-reducers/upgrade-reducer.ts @@ -1,10 +1,43 @@ import { Node } from '@ali/lowcode-designer'; -import { compatibleLegaoSchema } from '@ali/lowcode-utils'; +import { isPlainObject, isVariable } from '@ali/lowcode-utils'; +import { isJSBlock } from '@ali/lowcode-types'; import { designerCabin } from '@ali/lowcode-engine'; const { getConvertedExtraKey } = designerCabin; -export const upgradePropsReducer = compatibleLegaoSchema; +export function upgradePropsReducer(props: any): any { + if (!props || !isPlainObject(props)) { + return props; + } + + if (isJSBlock(props)) { + if (props.value.componentName === 'Slot') { + return { + type: 'JSSlot', + title: (props.value.props as any)?.slotTitle, + name: (props.value.props as any)?.slotName, + value: props.value.children, + }; + } else { + return props.value; + } + } + if (isVariable(props)) { + return { + type: 'JSExpression', + value: props.variable, + mock: props.value, + }; + } + const newProps: any = {}; + Object.keys(props).forEach((key) => { + if (/^__slot__/.test(key) && props[key] === true) { + return; + } + newProps[key] = upgradePropsReducer(props[key]); + }); + return newProps; +} export function upgradePageLifeCyclesReducer(props: any, node: Node) { const lifeCycleNames = ['didMount', 'willUnmount'];