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