mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 17:48:13 +00:00
style: react-provider
This commit is contained in:
parent
bdeb5becbb
commit
692288bae8
@ -8,7 +8,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
interface IState {
|
||||
schema: object | null;
|
||||
schema: Record<string, unknown> | null;
|
||||
hasError: boolean;
|
||||
}
|
||||
|
||||
@ -76,6 +76,6 @@ export default class LazyComponent extends Component<IProps, IState> {
|
||||
loading={Loading ? <Loading /> : null}
|
||||
{...restProps}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,11 +8,13 @@ import LazyComponent from './components/LazyComponent';
|
||||
export default class ReactProvider extends Provider {
|
||||
// 定制构造根组件的逻辑,如切换路由机制
|
||||
createApp() {
|
||||
let RouterView = this.getRouterView();
|
||||
const RouterView = this.getRouterView();
|
||||
let App: any;
|
||||
const layoutConfig = this.getLayoutConfig();
|
||||
if (!layoutConfig || !layoutConfig.componentName) {
|
||||
App = (props: any) => (RouterView ? createElement(RouterView, { ...props }) : null);
|
||||
App = (props: any) => {
|
||||
return (RouterView ? createElement(RouterView, { ...props }) : null);
|
||||
};
|
||||
return App;
|
||||
}
|
||||
const { componentName: layoutName, props: layoutProps } = layoutConfig;
|
||||
@ -25,7 +27,9 @@ export default class ReactProvider extends Provider {
|
||||
RouterView ? createElement(RouterView, props) : null,
|
||||
);
|
||||
} else {
|
||||
App = (props: any) => (RouterView ? createElement(RouterView, props) : null);
|
||||
App = (props: any) => {
|
||||
return (RouterView ? createElement(RouterView, props) : null);
|
||||
};
|
||||
}
|
||||
return App;
|
||||
}
|
||||
@ -83,13 +87,14 @@ export default class ReactProvider extends Provider {
|
||||
const appHelper = new AppHelper();
|
||||
appHelper.set('utils', this.getUtils());
|
||||
appHelper.set('constants', this.getConstants());
|
||||
const self = this;
|
||||
const RouterView = (props: any) => {
|
||||
return createElement(Router as any, {
|
||||
routes,
|
||||
components: this.getComponents(),
|
||||
utils: this.getUtils(),
|
||||
components: self.getComponents(),
|
||||
utils: self.getUtils(),
|
||||
appHelper,
|
||||
componentsMap: this.getComponentsMapObj(),
|
||||
componentsMap: self.getComponentsMapObj(),
|
||||
...props,
|
||||
});
|
||||
};
|
||||
@ -104,7 +109,10 @@ export default class ReactProvider extends Provider {
|
||||
return this.getLazyElement(pageId);
|
||||
} else {
|
||||
const lazyElement = createElement(LazyComponent as any, {
|
||||
getPageData: async () => await this.getPageData(pageId),
|
||||
getPageData: async () => {
|
||||
const pageData = await this.getPageData(pageId);
|
||||
return pageData;
|
||||
},
|
||||
key: pageId,
|
||||
context: this,
|
||||
...props,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user