mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-25 14:53:57 +00:00
feat: live mode lifeCycles
This commit is contained in:
parent
ab66fd4ca5
commit
66f0c79dec
@ -19,7 +19,7 @@ export function deepValueParser(obj?: any): any {
|
|||||||
}
|
}
|
||||||
// 兼容 ListSetter 中的变量结构
|
// 兼容 ListSetter 中的变量结构
|
||||||
if (isVariable(obj)) {
|
if (isVariable(obj)) {
|
||||||
if (editor.get('designMode') === 'live'){
|
if (editor.get('designMode') === 'live') {
|
||||||
return {
|
return {
|
||||||
type: 'JSExpression',
|
type: 'JSExpression',
|
||||||
value: obj.variable,
|
value: obj.variable,
|
||||||
|
|||||||
@ -138,11 +138,23 @@ designer.addPropsReducer((props, node) => {
|
|||||||
}, TransformStage.Init);
|
}, TransformStage.Init);
|
||||||
|
|
||||||
designer.addPropsReducer((props: any, node: Node) => {
|
designer.addPropsReducer((props: any, node: Node) => {
|
||||||
|
// live 模式下解析 lifeCycles
|
||||||
if (node.isRoot() && props && props.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 {
|
return {
|
||||||
...props,
|
...props,
|
||||||
lifeCycles: {},
|
lifeCycles: {},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
return props;
|
return props;
|
||||||
}, TransformStage.Render);
|
}, TransformStage.Render);
|
||||||
@ -220,6 +232,29 @@ designer.addPropsReducer((props: any, node: Node) => {
|
|||||||
return props;
|
return props;
|
||||||
}, TransformStage.Save);
|
}, 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) {
|
function stylePropsReducer(props: any, node: any) {
|
||||||
if (props && typeof props === 'object' && props.__style__) {
|
if (props && typeof props === 'object' && props.__style__) {
|
||||||
|
|||||||
@ -22,7 +22,6 @@ export default class PageEngine extends BaseEngine {
|
|||||||
static contextType = AppContext;
|
static contextType = AppContext;
|
||||||
|
|
||||||
static getDerivedStateFromProps(props, state) {
|
static getDerivedStateFromProps(props, state) {
|
||||||
debugger;
|
|
||||||
debug('page.getDerivedStateFromProps');
|
debug('page.getDerivedStateFromProps');
|
||||||
const func = props.__schema.lifeCycles && props.__schema.lifeCycles.getDerivedStateFromProps;
|
const func = props.__schema.lifeCycles && props.__schema.lifeCycles.getDerivedStateFromProps;
|
||||||
if (func) {
|
if (func) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user