mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
sperate props upgrade & init logic
This commit is contained in:
parent
6dc9ff8426
commit
0777c3c9d9
@ -520,7 +520,7 @@ export class DocumentModel {
|
||||
};
|
||||
}
|
||||
|
||||
setRendererReady(renderer) {
|
||||
setRendererReady(renderer: any) {
|
||||
this.emitter.emit('lowcode_engine_renderer_ready', renderer);
|
||||
}
|
||||
|
||||
|
||||
@ -157,17 +157,19 @@ 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.transformProps(props || {}), this.transformProps(extras || {}));
|
||||
this.props.import(this.upgradeProps(this.initProps(props || {})), this.upgradeProps(extras || {}));
|
||||
this.setupAutoruns();
|
||||
}
|
||||
|
||||
this.settingEntry = this.document.designer.createSettingEntry([ this ]);
|
||||
}
|
||||
|
||||
private transformProps(props: any): any {
|
||||
// FIXME! support PropsList
|
||||
private initProps(props: any): any {
|
||||
return this.document.designer.transformProps(props, this, TransformStage.Init);
|
||||
}
|
||||
private upgradeProps(props: any): any {
|
||||
return this.document.designer.transformProps(props, this, TransformStage.Upgrade);
|
||||
}
|
||||
|
||||
private autoruns?: Array<() => void>;
|
||||
private setupAutoruns() {
|
||||
@ -545,7 +547,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
const addon = this._addons[key];
|
||||
if (addon) {
|
||||
if (addon.isProp) {
|
||||
(props as any)[key] = addon.exportData();
|
||||
(props as any)[getConvertedExtraKey(key)] = addon.exportData();
|
||||
} else {
|
||||
_extras_[key] = addon.exportData();
|
||||
}
|
||||
|
||||
@ -74,14 +74,16 @@ function upgradePropsReducer(props: any) {
|
||||
return newProps;
|
||||
}
|
||||
// 升级 Props
|
||||
designer.addPropsReducer(upgradePropsReducer, TransformStage.Init);
|
||||
designer.addPropsReducer(upgradePropsReducer, TransformStage.Upgrade);
|
||||
|
||||
// 节点 props 初始化
|
||||
designer.addPropsReducer((props, node) => {
|
||||
// run initials
|
||||
const initials = node.componentMeta.getMetadata().experimental?.initials;
|
||||
if (initials) {
|
||||
const newProps: any = {};
|
||||
const newProps: any = {
|
||||
...props,
|
||||
};
|
||||
initials.forEach((item) => {
|
||||
// FIXME! this implements SettingTarget
|
||||
try {
|
||||
|
||||
@ -4,4 +4,5 @@ export enum TransformStage {
|
||||
Save = 3,
|
||||
Clone = 4,
|
||||
Init = 5,
|
||||
Upgrade = 6,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user