mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 12:50:38 +00:00
fix: 调整 upgrade 和 init 的流程
This commit is contained in:
parent
5cfd57d16b
commit
09fc1a06c9
@ -159,7 +159,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
this.props = new Props(this, props, extras);
|
this.props = new Props(this, props, extras);
|
||||||
this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children));
|
this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children));
|
||||||
this._children.interalInitParent();
|
this._children.interalInitParent();
|
||||||
this.props.import(this.initProps(this.upgradeProps(props || {})), this.upgradeProps(extras || {}));
|
this.props.import(this.upgradeProps(this.initProps(props || {})), this.upgradeProps(extras || {}));
|
||||||
this.setupAutoruns();
|
this.setupAutoruns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -85,17 +85,35 @@ designer.addPropsReducer((props, node) => {
|
|||||||
const newProps: any = {
|
const newProps: any = {
|
||||||
...props,
|
...props,
|
||||||
};
|
};
|
||||||
|
const getRealValue = (propValue: any) => {
|
||||||
|
if (isVariable(propValue)) {
|
||||||
|
return propValue.value;
|
||||||
|
}
|
||||||
|
if (isJSExpression(propValue)) {
|
||||||
|
return propValue.mock;
|
||||||
|
}
|
||||||
|
return propValue;
|
||||||
|
};
|
||||||
initials.forEach((item) => {
|
initials.forEach((item) => {
|
||||||
// FIXME! this implements SettingTarget
|
// FIXME! this implements SettingTarget
|
||||||
try {
|
try {
|
||||||
// FIXME! item.name could be 'xxx.xxx'
|
// FIXME! item.name could be 'xxx.xxx'
|
||||||
const ov = props[item.name];
|
const ov = props[item.name];
|
||||||
const v = item.initial(node as any, isJSExpression(ov) ? ov.mock : ov);
|
const v = item.initial(node as any, getRealValue(ov));
|
||||||
if (v !== undefined) {
|
if (v !== undefined) {
|
||||||
newProps[item.name] = isJSExpression(ov) ? {
|
if (isVariable(ov)) {
|
||||||
...ov,
|
newProps[item.name] = {
|
||||||
mock: v,
|
...ov,
|
||||||
} : v;
|
value: v,
|
||||||
|
};
|
||||||
|
} else if (isJSExpression(ov)) {
|
||||||
|
newProps[item.name] = {
|
||||||
|
...ov,
|
||||||
|
mock: v,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
newProps[item.name] = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (hasOwnProperty(props, item.name)) {
|
if (hasOwnProperty(props, item.name)) {
|
||||||
|
|||||||
@ -248,8 +248,8 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
|
|||||||
const _leaf = host.document.designer.currentDocument?.createNode(schema);
|
const _leaf = host.document.designer.currentDocument?.createNode(schema);
|
||||||
const node = host.document.createNode(schema);
|
const node = host.document.createNode(schema);
|
||||||
let { props } = schema;
|
let { props } = schema;
|
||||||
props = host.document.designer.transformProps(props, node, TransformStage.Upgrade);
|
|
||||||
props = host.document.designer.transformProps(props, node, TransformStage.Init);
|
props = host.document.designer.transformProps(props, node, TransformStage.Init);
|
||||||
|
props = host.document.designer.transformProps(props, node, TransformStage.Upgrade);
|
||||||
props = processPropsSchema(props, propsMap);
|
props = processPropsSchema(props, propsMap);
|
||||||
props = host.document.designer.transformProps(props, node, TransformStage.Render);
|
props = host.document.designer.transformProps(props, node, TransformStage.Render);
|
||||||
return createElement(Com, { ...props, _leaf }, children);
|
return createElement(Com, { ...props, _leaf }, children);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user