fix: compatiableReducer 递归

This commit is contained in:
mario.gk 2020-08-19 12:12:21 +08:00
parent 48c2805775
commit e905928ab3

View File

@ -174,33 +174,33 @@ designer.addPropsReducer(filterReducer, TransformStage.Save);
designer.addPropsReducer(filterReducer, TransformStage.Render); designer.addPropsReducer(filterReducer, TransformStage.Render);
function compatiableReducer(props: any) { function compatiableReducer(props: any) {
if (!isPlainObject(props)) { if (!props || !isPlainObject(props)) {
return props; return props;
} }
const newProps: any = {}; if (isJSSlot(props)) {
Object.entries<any>(props).forEach(([key, val]) => { return {
if (isJSSlot(val)) {
val = {
type: 'JSBlock', type: 'JSBlock',
value: { value: {
componentName: 'Slot', componentName: 'Slot',
children: val.value, children: props.value,
props: { props: {
slotTitle: val.title, slotTitle: props.title,
slotName: val.name, slotName: props.name,
}, },
}, },
}; };
} }
// 为了能降级到老版本,建议在后期版本去掉以下代码 // 为了能降级到老版本,建议在后期版本去掉以下代码
if (isJSExpression(val) && !val.events) { if (isJSExpression(props) && !props.events) {
val = { return {
type: 'variable', type: 'variable',
value: val.mock, value: props.mock,
variable: val.value, variable: props.value,
} }
} }
newProps[key] = val; const newProps: any = {};
Object.entries<any>(props).forEach(([key, val]) => {
newProps[key] = compatiableReducer(val);
}); });
return newProps; return newProps;
} }