refactor: 支持 slot 转换后 params 参数保留

This commit is contained in:
荣彬 2021-05-22 23:52:08 +08:00 committed by 力皓
parent b3b76d9ba0
commit 39ba2bf6ef
3 changed files with 13 additions and 10 deletions

View File

@ -18,6 +18,7 @@ export function compatibleReducer(props: any) {
slotTitle: props.title,
slotName: props.name,
},
__params__: props.params,
},
};
}

View File

@ -27,6 +27,7 @@ export function compatibleLegaoSchema(props: any): any {
title: (props.value.props as any)?.slotTitle,
name: (props.value.props as any)?.slotName,
value: props.value.children,
params: (props.value.props as any)?.__params__,
};
} else {
return props.value;
@ -44,11 +45,11 @@ export function compatibleLegaoSchema(props: any): any {
if (/^__slot__/.test(key) && props[key] === true) {
return;
}
// TODO: 目前 dataSource 面板里既用到了 JSExpression又用到了 variable这里先都不处理后面再重构
if (key === 'dataSource') {
newProps[key] = props[key];
return;
}
// TODO: 先移除,目前没有业务使用
// if (key === 'dataSource') {
// newProps[key] = props[key];
// return;
// }
newProps[key] = compatibleLegaoSchema(props[key]);
});
return newProps;

View File

@ -24,6 +24,7 @@ export function compatibleReducer(props: any, node: Node): any {
slotName: props.name,
},
},
__params__: props.params,
};
}
if (isJSExpression(props) && !props.events) {
@ -35,11 +36,11 @@ export function compatibleReducer(props: any, node: Node): any {
}
const newProps: any = {};
Object.entries<any>(props).forEach(([key, val]) => {
// TODO: 目前 dataSource 面板里既用到了 JSExpression又用到了 variable这里先都不处理后面再重构
if (key === 'dataSource') {
newProps[key] = props[key];
return;
}
// // TODO: 目前 dataSource 面板里既用到了 JSExpression又用到了 variable这里先都不处理后面再重构
// if (key === 'dataSource') {
// newProps[key] = props[key];
// return;
// }
newProps[key] = compatibleReducer(val, node);
});
return newProps;