Merge branch 'feat/rax-miniapp' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into feat/rax-miniapp

This commit is contained in:
carlos.czw 2020-08-20 00:34:52 +08:00
commit 8029905ffd
2 changed files with 35 additions and 1 deletions

View File

@ -137,7 +137,19 @@ designer.addPropsReducer((props, node) => {
}, TransformStage.Init);
designer.addPropsReducer((props: any, node: Node) => {
// live 模式下解析 lifeCycles
if (node.isRoot() && props && props.lifeCycles) {
if (editor.get('designMode') === 'live') {
const lifeCycleMap = {
didMount: 'componentDidMount',
willUnmount: 'componentWillUnMount',
};
const lifeCycles = props.lifeCycles;
Object.keys(lifeCycleMap).forEach(key => {
lifeCycles[lifeCycleMap[key]] = lifeCycles[key];
});
return props;
}
return {
...props,
lifeCycles: {},
@ -219,6 +231,29 @@ designer.addPropsReducer((props: any, node: Node) => {
return props;
}, TransformStage.Save);
// designer.addPropsReducer((props: any, node: Node) => {
// const lifeCycleNames = ['didMount', 'willUnmount'];
// const lifeCycleMap = {
// didMount: 'componentDidMount',
// willUnmount: 'componentWillUnMount',
// };
// if (node.componentName === 'Page') {
// debugger;
// lifeCycleNames.forEach(key => {
// if (props[key]) {
// const lifeCycles = node.props.getPropValue(getConvertedExtraKey('lifeCycles')) || {};
// lifeCycles[lifeCycleMap[key]] = props[key];
// node.props.setPropValue(getConvertedExtraKey('lifeCycles'), lifeCycles);
// } else if (node.props.getPropValue(getConvertedExtraKey('lifeCycles'))) {
// const lifeCycles = node.props.getPropValue(getConvertedExtraKey('lifeCycles')) || {};
// lifeCycles[lifeCycleMap[key]] = lifeCycles[key];
// node.props.setPropValue(getConvertedExtraKey('lifeCycles'), lifeCycles);
// }
// });
// }
// return props;
// }, TransformStage.Init);
// 设计器组件样式处理
function stylePropsReducer(props: any, node: any) {
if (props && typeof props === 'object' && props.__style__) {

View File

@ -22,7 +22,6 @@ export default class PageEngine extends BaseEngine {
static contextType = AppContext;
static getDerivedStateFromProps(props, state) {
// debugger;
debug('page.getDerivedStateFromProps');
const func = props.__schema.lifeCycles && props.__schema.lifeCycles.getDerivedStateFromProps;
if (func) {