mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 22:58:15 +00:00
fix: 修复数据源的接入问题
This commit is contained in:
parent
a8a17492e9
commit
98ae1ed82c
@ -11,6 +11,19 @@
|
|||||||
"fileName": "test",
|
"fileName": "test",
|
||||||
"dataSource": {
|
"dataSource": {
|
||||||
"list": [
|
"list": [
|
||||||
|
{
|
||||||
|
"type": "fetch",
|
||||||
|
"id": "请求商家数据,是一个 HTTP 请求,是一个 HTTP 请求,是一个 HTTP 请求",
|
||||||
|
"isInit": true,
|
||||||
|
"options": {
|
||||||
|
"uri": "https://www.taobao.com",
|
||||||
|
"params": {
|
||||||
|
"a": 1,
|
||||||
|
"b": true,
|
||||||
|
"c": "3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
|
|||||||
@ -135,6 +135,12 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
return this.get('designMode') || 'design';
|
return this.get('designMode') || 'design';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed get requestHandlersMap(): any {
|
||||||
|
// renderer 依赖
|
||||||
|
// TODO: 需要根据 design mode 不同切换鼠标响应情况
|
||||||
|
return this.get('requestHandlersMap') || null;
|
||||||
|
}
|
||||||
|
|
||||||
@computed get componentsAsset(): Asset | undefined {
|
@computed get componentsAsset(): Asset | undefined {
|
||||||
return this.get('componentsAsset');
|
return this.get('componentsAsset');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ interface DesignerPluginState {
|
|||||||
renderEnv?: string;
|
renderEnv?: string;
|
||||||
device?: string;
|
device?: string;
|
||||||
simulatorUrl: Asset | null;
|
simulatorUrl: Asset | null;
|
||||||
|
requestHandlersMap: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class DesignerPlugin extends PureComponent<PluginProps, DesignerPluginState> {
|
export default class DesignerPlugin extends PureComponent<PluginProps, DesignerPluginState> {
|
||||||
@ -27,6 +28,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
renderEnv: 'default',
|
renderEnv: 'default',
|
||||||
device: 'default',
|
device: 'default',
|
||||||
simulatorUrl: null,
|
simulatorUrl: null,
|
||||||
|
requestHandlersMap: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
private _mounted = true;
|
private _mounted = true;
|
||||||
@ -43,6 +45,8 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
const renderEnv = await editor.get('renderEnv');
|
const renderEnv = await editor.get('renderEnv');
|
||||||
const device = await editor.get('device');
|
const device = await editor.get('device');
|
||||||
const simulatorUrl = await editor.get('simulatorUrl');
|
const simulatorUrl = await editor.get('simulatorUrl');
|
||||||
|
// @TODO setupAssets 里设置 requestHandlersMap 不太合适
|
||||||
|
const requestHandlersMap = await editor.get('requestHandlersMap');
|
||||||
if (!this._mounted) {
|
if (!this._mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -54,6 +58,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
renderEnv,
|
renderEnv,
|
||||||
device,
|
device,
|
||||||
simulatorUrl,
|
simulatorUrl,
|
||||||
|
requestHandlersMap,
|
||||||
};
|
};
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -76,7 +81,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
|
|
||||||
render(): React.ReactNode {
|
render(): React.ReactNode {
|
||||||
const { editor } = this.props;
|
const { editor } = this.props;
|
||||||
const { componentMetadatas, library, extraEnvironment, renderEnv, device, simulatorUrl } = this.state;
|
const { componentMetadatas, library, extraEnvironment, renderEnv, device, simulatorUrl, requestHandlersMap } = this.state;
|
||||||
if (!library || !componentMetadatas) {
|
if (!library || !componentMetadatas) {
|
||||||
// TODO: use a Loading
|
// TODO: use a Loading
|
||||||
return null;
|
return null;
|
||||||
@ -95,6 +100,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
renderEnv,
|
renderEnv,
|
||||||
device,
|
device,
|
||||||
simulatorUrl,
|
simulatorUrl,
|
||||||
|
requestHandlersMap,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -178,9 +178,10 @@ export default class BaseEngine extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 设置容器组件占位,若设置占位则在初始异步请求完成之前用loading占位且不渲染容器组件内部内容
|
// 设置容器组件占位,若设置占位则在初始异步请求完成之前用loading占位且不渲染容器组件内部内容
|
||||||
if (this.__parseData(schema.props && schema.props.autoLoading)) {
|
// @TODO __showPlaceholder 的逻辑一旦开启就关不掉,先注释掉了
|
||||||
|
/* if (this.__parseData(schema.props && schema.props.autoLoading)) {
|
||||||
this.__showPlaceholder = (dataSource.list || []).some((item) => !!this.__parseData(item.isInit));
|
this.__showPlaceholder = (dataSource.list || []).some((item) => !!this.__parseData(item.isInit));
|
||||||
}
|
} */
|
||||||
};
|
};
|
||||||
|
|
||||||
__render = () => {
|
__render = () => {
|
||||||
|
|||||||
@ -156,6 +156,7 @@ export default class BaseRender extends PureComponent {
|
|||||||
this.__showPlaceholder = true;
|
this.__showPlaceholder = true;
|
||||||
reloadDataSource().then(() => {
|
reloadDataSource().then(() => {
|
||||||
this.__showPlaceholder = false;
|
this.__showPlaceholder = false;
|
||||||
|
// this.forceUpdate();
|
||||||
// @TODO 是否需要 forceUpate
|
// @TODO 是否需要 forceUpate
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
@ -190,9 +191,10 @@ export default class BaseRender extends PureComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 设置容器组件占位,若设置占位则在初始异步请求完成之前用loading占位且不渲染容器组件内部内容
|
// 设置容器组件占位,若设置占位则在初始异步请求完成之前用loading占位且不渲染容器组件内部内容
|
||||||
this.__showPlaceholder = this.__parseData(schema.props && schema.props.autoLoading) && (dataSource.list || []).some(
|
// @TODO __showPlaceholder 的逻辑一旦开启就关不掉,先注释掉了
|
||||||
|
/* this.__showPlaceholder = this.__parseData(schema.props && schema.props.autoLoading) && (dataSource.list || []).some(
|
||||||
(item) => !!this.__parseData(item.isInit),
|
(item) => !!this.__parseData(item.isInit),
|
||||||
);
|
); */
|
||||||
};
|
};
|
||||||
|
|
||||||
__render = () => {
|
__render = () => {
|
||||||
|
|||||||
@ -98,14 +98,14 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { renderer } = this.props;
|
const { renderer } = this.props;
|
||||||
const { device, designMode } = renderer;
|
const { device, designMode, requestHandlersMap } = renderer;
|
||||||
return (
|
return (
|
||||||
<LowCodeRenderer
|
<LowCodeRenderer
|
||||||
schema={renderer.schema}
|
schema={renderer.schema}
|
||||||
components={renderer.components}
|
components={renderer.components}
|
||||||
appHelper={renderer.context}
|
appHelper={renderer.context}
|
||||||
// context={renderer.context}
|
// context={renderer.context}
|
||||||
requestHandlersMap={host.requestHandlersMap}
|
requestHandlersMap={requestHandlersMap}
|
||||||
designMode={designMode}
|
designMode={designMode}
|
||||||
device={device}
|
device={device}
|
||||||
suspended={renderer.suspended}
|
suspended={renderer.suspended}
|
||||||
|
|||||||
@ -48,6 +48,8 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
|
|||||||
// sync designMode
|
// sync designMode
|
||||||
this._designMode = host.designMode;
|
this._designMode = host.designMode;
|
||||||
|
|
||||||
|
this._requestHandlersMap = host.requestHandlersMap;
|
||||||
|
|
||||||
// sync suspended
|
// sync suspended
|
||||||
|
|
||||||
// sync scope
|
// sync scope
|
||||||
@ -114,6 +116,12 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
|
|||||||
return this._designMode;
|
return this._designMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@obx.ref private _requestHandlersMap = null;
|
||||||
|
|
||||||
|
@computed get requestHandlersMap(): any {
|
||||||
|
return this._requestHandlersMap;
|
||||||
|
}
|
||||||
|
|
||||||
@obx.ref private _device = 'default';
|
@obx.ref private _device = 'default';
|
||||||
|
|
||||||
@computed get device() {
|
@computed get device() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user