mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 05:48:17 +00:00
fix: 修复最小渲染单元问题 & 修复设计态使用数据源引擎的情况下,dataSourceMap 会被清除
This commit is contained in:
parent
33f0fb43c9
commit
f921f3c7b0
@ -18,6 +18,7 @@
|
|||||||
"@ali/lib-mtop": "^2.5.1",
|
"@ali/lib-mtop": "^2.5.1",
|
||||||
"@ali/lowcode-datasource-engine": "^1.0.22",
|
"@ali/lowcode-datasource-engine": "^1.0.22",
|
||||||
"@ali/lowcode-types": "1.0.72",
|
"@ali/lowcode-types": "1.0.72",
|
||||||
|
"@ali/lowcode-utils": "1.0.72",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"fetch-jsonp": "^1.1.3",
|
"fetch-jsonp": "^1.1.3",
|
||||||
|
|||||||
@ -9,12 +9,7 @@ export function compWrapper(Comp: any) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { forwardRef, ...rest } = this.props;
|
return createElement(Comp, this.props);
|
||||||
|
|
||||||
return createElement(Comp, {
|
|
||||||
...rest,
|
|
||||||
ref: forwardRef,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -316,12 +316,12 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
makeUnitRender() {
|
makeUnitRender = () => {
|
||||||
this.beforeRender(RerenderType.MinimalRenderUnit);
|
this.beforeRender(RerenderType.MinimalRenderUnit);
|
||||||
const nextProps = getProps(this.leaf?.export?.(TransformStage.Render) as types.ISchema, scope, Comp, componentInfo);
|
const nextProps = getProps(this.leaf?.export?.(TransformStage.Render) as types.ISchema, scope, Comp, componentInfo);
|
||||||
const children = getChildren(this.leaf?.export?.(TransformStage.Render) as types.ISchema, scope, Comp);
|
const children = getChildren(this.leaf?.export?.(TransformStage.Render) as types.ISchema, scope, Comp);
|
||||||
const nextState = {
|
const nextState = {
|
||||||
nextProps,
|
nodeProps: nextProps,
|
||||||
nodeChildren: children,
|
nodeChildren: children,
|
||||||
childrenInState: true,
|
childrenInState: true,
|
||||||
};
|
};
|
||||||
@ -331,7 +331,7 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
|
|
||||||
__debug(`${this.leaf?.componentName}(${this.props.componentId}) MinimalRenderUnit Render!`);
|
__debug(`${this.leaf?.componentName}(${this.props.componentId}) MinimalRenderUnit Render!`);
|
||||||
this.setState(nextState);
|
this.setState(nextState);
|
||||||
}
|
};
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps: any) {
|
componentWillReceiveProps(nextProps: any) {
|
||||||
let { _leaf, componentId } = nextProps;
|
let { _leaf, componentId } = nextProps;
|
||||||
|
|||||||
@ -224,10 +224,12 @@ export default function baseRenererFactory() {
|
|||||||
const dataSource = (schema && schema.dataSource) || {};
|
const dataSource = (schema && schema.dataSource) || {};
|
||||||
// requestHandlersMap 存在才走数据源引擎方案
|
// requestHandlersMap 存在才走数据源引擎方案
|
||||||
if (props?.__appHelper?.requestHandlersMap) {
|
if (props?.__appHelper?.requestHandlersMap) {
|
||||||
const { dataSourceMap, reloadDataSource } = createDataSourceEngine(dataSource, (this as any), {
|
this.__dataHelper = {
|
||||||
|
updateConfig: (updateDataSource: any) => {
|
||||||
|
const { dataSourceMap, reloadDataSource } = createDataSourceEngine(updateDataSource, (this as any), {
|
||||||
requestHandlersMap: props.__appHelper.requestHandlersMap,
|
requestHandlersMap: props.__appHelper.requestHandlersMap,
|
||||||
});
|
});
|
||||||
this.dataSourceMap = dataSourceMap;
|
|
||||||
this.reloadDataSource = () => new Promise((resolve) => {
|
this.reloadDataSource = () => new Promise((resolve) => {
|
||||||
this.__debug('reload data source');
|
this.__debug('reload data source');
|
||||||
// this.__showPlaceholder = true;
|
// this.__showPlaceholder = true;
|
||||||
@ -238,6 +240,10 @@ export default function baseRenererFactory() {
|
|||||||
resolve({});
|
resolve({});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
return dataSourceMap;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this.dataSourceMap = this.__dataHelper.updateConfig(dataSource);
|
||||||
} else {
|
} else {
|
||||||
const appHelper = props.__appHelper;
|
const appHelper = props.__appHelper;
|
||||||
this.__dataHelper = new DataHelper(this, dataSource, appHelper, (config: any) => this.__parseData(config));
|
this.__dataHelper = new DataHelper(this, dataSource, appHelper, (config: any) => this.__parseData(config));
|
||||||
@ -531,7 +537,7 @@ export default function baseRenererFactory() {
|
|||||||
props.key = props.__id;
|
props.key = props.__id;
|
||||||
}
|
}
|
||||||
|
|
||||||
let child: any = parentInfo.componentChildren || this.__getSchemaChildrenVirtualDom(schema, scope, Comp);
|
let child: any = this.__getSchemaChildrenVirtualDom(schema, scope, Comp);
|
||||||
const renderComp = (props: any) => engine.createElement(Comp, props, child);
|
const renderComp = (props: any) => engine.createElement(Comp, props, child);
|
||||||
// 设计模式下的特殊处理
|
// 设计模式下的特殊处理
|
||||||
if (engine && [DESIGN_MODE.EXTEND, DESIGN_MODE.BORDER].includes(engine.props.designMode)) {
|
if (engine && [DESIGN_MODE.EXTEND, DESIGN_MODE.BORDER].includes(engine.props.designMode)) {
|
||||||
@ -590,7 +596,7 @@ export default function baseRenererFactory() {
|
|||||||
.map((d: IComponentHoc) => d.hoc);
|
.map((d: IComponentHoc) => d.hoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
__getSchemaChildrenVirtualDom = (schema: ISchema, scope: any, Comp: any, childrenMap?: Map<any, any>) => {
|
__getSchemaChildrenVirtualDom = (schema: ISchema, scope: any, Comp: any) => {
|
||||||
let _children = this.getSchemaChildren(schema);
|
let _children = this.getSchemaChildren(schema);
|
||||||
|
|
||||||
let children: any = [];
|
let children: any = [];
|
||||||
@ -606,8 +612,6 @@ export default function baseRenererFactory() {
|
|||||||
{
|
{
|
||||||
schema,
|
schema,
|
||||||
Comp,
|
Comp,
|
||||||
// 有 childrenMap 情况下,children 只计算第一层,不需要遍历多层。
|
|
||||||
componentChildren: childrenMap?.get(_child.id)?.props.children || null,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user