mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 04:40:32 +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._children = new NodeChildren(this as ParentalNode, this.initialChildren(children));
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@ -85,17 +85,35 @@ designer.addPropsReducer((props, node) => {
|
||||
const newProps: any = {
|
||||
...props,
|
||||
};
|
||||
const getRealValue = (propValue: any) => {
|
||||
if (isVariable(propValue)) {
|
||||
return propValue.value;
|
||||
}
|
||||
if (isJSExpression(propValue)) {
|
||||
return propValue.mock;
|
||||
}
|
||||
return propValue;
|
||||
};
|
||||
initials.forEach((item) => {
|
||||
// FIXME! this implements SettingTarget
|
||||
try {
|
||||
// FIXME! item.name could be 'xxx.xxx'
|
||||
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) {
|
||||
newProps[item.name] = isJSExpression(ov) ? {
|
||||
...ov,
|
||||
mock: v,
|
||||
} : v;
|
||||
if (isVariable(ov)) {
|
||||
newProps[item.name] = {
|
||||
...ov,
|
||||
value: v,
|
||||
};
|
||||
} else if (isJSExpression(ov)) {
|
||||
newProps[item.name] = {
|
||||
...ov,
|
||||
mock: v,
|
||||
};
|
||||
} else {
|
||||
newProps[item.name] = v;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (hasOwnProperty(props, item.name)) {
|
||||
|
||||
@ -248,8 +248,8 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
|
||||
const _leaf = host.document.designer.currentDocument?.createNode(schema);
|
||||
const node = host.document.createNode(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.Upgrade);
|
||||
props = processPropsSchema(props, propsMap);
|
||||
props = host.document.designer.transformProps(props, node, TransformStage.Render);
|
||||
return createElement(Com, { ...props, _leaf }, children);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user