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