feat: 支持在 host 里刷新渲染器

This commit is contained in:
力皓 2021-05-13 20:47:15 +08:00
parent bf4302b381
commit ccbbf743ad
3 changed files with 20 additions and 1 deletions

View File

@ -309,6 +309,11 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
return libraryAsset;
}
rerender() {
this.designer.refreshComponentMetasMap();
this.renderer?.rerender?.();
}
async mountContentFrame(iframe: HTMLIFrameElement | null) {
if (!iframe || this._iframe === iframe) {
return;

View File

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

View File

@ -474,6 +474,14 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
host.project.setRendererReady(this);
}
/**
*
*/
rerender() {
// TODO: 不太优雅
this._appContext = { ...this._appContext };
}
dispose() {
this.disposeFunctions.forEach(fn => fn());
this.documentInstances.forEach(docInst => docInst.dispose());