| 5 | const PluginCore = (ctx: IPublicModelPluginContext, options: any) => { |
| 6 | return { |
| 7 | async init() { |
| 8 | const { material, project, plugins } = ctx; |
| 9 | const { assets, schema } = options; |
| 10 | await plugins.register(Inject); |
| 11 | // 注册 components,加载所有的 meta js |
| 12 | await material.setAssets(await injectAssets(assets)); |
| 13 | |
| 14 | // 加载 schema |
| 15 | project.openDocument(schema); |
| 16 | |
| 17 | // 简单处理 init 时候直接 load 所有组件 view |
| 18 | const loader = new AssetLoader(); |
| 19 | const componentsAssets = assets.packages.map((asset: any) => asset.urls).flat(); |
| 20 | await loader.load(componentsAssets); |
| 21 | }, |
| 22 | } |
| 23 | } |
| 24 | |