mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
fix: 修复无法获取 libraryMap
refactor: 移除 setupComponents, 直接调用 renderer 的 load/buildComponents 函数, 确保多个 renderer 都能 work
This commit is contained in:
parent
c463b73580
commit
393d9cebf8
@ -261,6 +261,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
const libraryAsset: AssetList = [];
|
||||
if (library) {
|
||||
library.forEach((item) => {
|
||||
this.libraryMap[item.package] = item.library;
|
||||
if (item.async) {
|
||||
this.asyncLibraryMap[item.package] = item;
|
||||
}
|
||||
@ -342,7 +343,8 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
|
||||
async setupComponents(library) {
|
||||
const libraryAsset: AssetList = this.buildLibrary(library);
|
||||
await this.renderer.setupComponents(libraryAsset);
|
||||
await this.renderer.load(libraryAsset);
|
||||
await this.renderer.buildComponents();
|
||||
}
|
||||
|
||||
setupEvents() {
|
||||
|
||||
@ -374,12 +374,12 @@ export class Designer {
|
||||
this.props = props;
|
||||
}
|
||||
|
||||
async loadIncrementalAssets(incrementalAssets: AssetsJson): void {
|
||||
async loadIncrementalAssets(incrementalAssets: AssetsJson): Promise<void> {
|
||||
const { components, packages } = incrementalAssets;
|
||||
components && this.buildComponentMetasMap(components);
|
||||
// 部分异步组件会在外层加载components,这里需要进行强制刷新
|
||||
this.forceUpdateComponentsMap();
|
||||
await this.project.simulator.setupComponents(packages);
|
||||
if (packages) {
|
||||
await this.project.simulator!.setupComponents(packages);
|
||||
}
|
||||
|
||||
if (components) {
|
||||
// 合并assets
|
||||
@ -387,6 +387,8 @@ export class Designer {
|
||||
let newAssets = megreAssets(assets, incrementalAssets);
|
||||
this.editor.set('assets', newAssets);
|
||||
}
|
||||
// TODO: 因为涉及修改 prototype.view,之后在 renderer 里修改了 vc 的 view 获取逻辑后,可删除
|
||||
this._componentMetasMap = new Map(this._componentMetasMap);
|
||||
// 完成加载增量资源后发送事件,方便插件监听并处理相关逻辑
|
||||
this.editor.emit('designer.incrementalAssetsReady');
|
||||
|
||||
@ -503,13 +505,6 @@ export class Designer {
|
||||
return maps;
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制刷新 componentsMap,使画布能拿到最新的组件
|
||||
*/
|
||||
private forceUpdateComponentsMap() {
|
||||
this._componentMetasMap = new Map(this._componentMetasMap);
|
||||
}
|
||||
|
||||
private propsReducers = new Map<TransformStage, PropsReducer[]>();
|
||||
|
||||
transformProps(props: CompositeObject | PropsList, node: Node, stage: TransformStage) {
|
||||
|
||||
@ -348,20 +348,15 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
||||
/**
|
||||
* 加载资源
|
||||
*/
|
||||
// load(asset: Asset): Promise<any> {
|
||||
// return loader.load(asset);
|
||||
// }
|
||||
load(asset: Asset): Promise<any> {
|
||||
return loader.load(asset);
|
||||
}
|
||||
|
||||
async loadAsyncLibrary(asyncLibraryMap) {
|
||||
await loader.loadAsyncLibrary(asyncLibraryMap);
|
||||
this.buildComponents();
|
||||
}
|
||||
|
||||
async setupComponents(asset: Asset) {
|
||||
await loader.load(asset);
|
||||
this.buildComponents();
|
||||
}
|
||||
|
||||
getComponent(componentName: string) {
|
||||
const paths = componentName.split('.');
|
||||
const subs: string[] = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user