Merge branch 'feat/autoRender' into 'release/1.0.51'

feat: 支持 disableAutoRender 配置项



See merge request !1273446
This commit is contained in:
高凯 2021-06-02 12:26:50 +08:00
commit 2e8545b51c
4 changed files with 20 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import { obx, autorun, computed, getPublicPath, hotkey, focusTracker } from '@ali/lowcode-editor-core';
import { obx, autorun, computed, getPublicPath, hotkey, focusTracker, engineConfig } from '@ali/lowcode-editor-core';
import { EventEmitter } from 'events';
import { ISimulatorHost, Component, NodeInstance, ComponentInstance, DropContainer } from '../simulator';
import Viewport from './viewport';
@ -138,10 +138,16 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
readonly emitter: EventEmitter = new EventEmitter();
/**
*
*/
autoRender = true;
constructor(project: Project) {
this.project = project;
this.designer = project?.designer;
this.scroller = this.designer.createScroller(this.viewport);
this.autoRender = engineConfig.get('disableAutoRender') !== true;
}
get currentDocument() {

View File

@ -191,6 +191,10 @@ interface EngineOptions {
*
*/
enableReactiveContainer?: boolean;
/**
*
*/
disableAutoRender?: boolean;
[key: string]: any;
}

View File

@ -141,6 +141,7 @@ class Renderer extends Component<{
const { designMode, device, locale } = container;
const messages = container.context?.utils?.i18n?.messages || {};
if (!container.autoRender) return null;
return (
// @ts-ignore
<LowCodeRenderer

View File

@ -243,6 +243,8 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
}
constructor() {
this.autoRender = host.autoRender;
this.disposeFunctions.push(host.connect(this, () => {
// sync layout config
this._layout = host.project.get('config').layout;
@ -386,6 +388,11 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
@computed get componentsMap(): any {
return this._componentsMap;
}
/**
*
*/
autoRender = true;
/**
*
*/
@ -523,6 +530,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
*
*/
rerender() {
this.autoRender = true;
// TODO: 不太优雅
this._appContext = { ...this._appContext };
}