refactor: 增加组件后, 重新构造 components, 但不触发重新渲染

This commit is contained in:
力皓 2021-04-14 14:05:57 +08:00
parent 70577adc7f
commit 936ad91913
3 changed files with 5 additions and 3 deletions

View File

@ -388,7 +388,7 @@ export class Designer {
this.editor.set('assets', newAssets);
}
// TODO: 因为涉及修改 prototype.view之后在 renderer 里修改了 vc 的 view 获取逻辑后,可删除
// this._componentMetasMap = new Map(this._componentMetasMap);
this._componentMetasMap = new Map(this._componentMetasMap);
// 完成加载增量资源后发送事件,方便插件监听并处理相关逻辑
this.editor.emit('designer.incrementalAssetsReady');

View File

@ -18,3 +18,5 @@ Object.defineProperty(window, 'React', {
});
window.scrollTo = () => {};
window.console.warn = () => {};

View File

@ -309,9 +309,9 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
...this._components,
};
}
@obx.ref private _components: any = {};
private _components: any = {};
@computed get components(): object {
get components(): object {
// 根据 device 选择不同组件,进行响应式
// 更好的做法是,根据 device 选择加载不同的组件资源,甚至是 simulatorUrl
return this._components;