mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-23 17:49:49 +08:00
allow pass-in external component, trait and module
This commit is contained in:
parent
c8d9fcd8b2
commit
db3d6dd213
@ -1,6 +1,7 @@
|
||||
import { ChakraProvider } from '@chakra-ui/react';
|
||||
import { Application } from '@meta-ui/core';
|
||||
import { initMetaUI } from '@meta-ui/runtime';
|
||||
import { Registry } from '@meta-ui/runtime/lib/services/registry';
|
||||
import { StrictMode } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import 'react-grid-layout/css/styles.css';
|
||||
@ -10,7 +11,16 @@ import { Editor } from './components/Editor';
|
||||
import { DefaultAppSchema } from './constants';
|
||||
import { AppModelManager } from './operations/AppModelManager';
|
||||
|
||||
export default function renderApp(app: Application = DefaultAppSchema) {
|
||||
type Options = Partial<{
|
||||
components: Parameters<Registry['registerComponent']>[0][];
|
||||
traits: Parameters<Registry['registerTrait']>[0][];
|
||||
modules: Parameters<Registry['registerModule']>[0][];
|
||||
}>;
|
||||
|
||||
export default function renderApp(
|
||||
app: Application = DefaultAppSchema,
|
||||
options: Options = {}
|
||||
) {
|
||||
const metaUI = initMetaUI();
|
||||
|
||||
const App = metaUI.App;
|
||||
@ -18,6 +28,11 @@ export default function renderApp(app: Application = DefaultAppSchema) {
|
||||
const stateStore = metaUI.stateManager.store;
|
||||
const appModelManager = new AppModelManager(app, registry);
|
||||
|
||||
const { components = [], traits = [], modules = [] } = options;
|
||||
components.forEach(c => registry.registerComponent(c));
|
||||
traits.forEach(t => registry.registerTrait(t));
|
||||
modules.forEach(m => registry.registerModule(m));
|
||||
|
||||
ReactDOM.render(
|
||||
<StrictMode>
|
||||
<ChakraProvider>
|
||||
|
Loading…
Reference in New Issue
Block a user