feat: 支持 disableAutoRender 配置项

This commit is contained in:
力皓 2021-06-02 11:13:28 +08:00
parent 61f1c2ec5a
commit 719928a02c
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 { EventEmitter } from 'events';
import { ISimulatorHost, Component, NodeInstance, ComponentInstance, DropContainer } from '../simulator'; import { ISimulatorHost, Component, NodeInstance, ComponentInstance, DropContainer } from '../simulator';
import Viewport from './viewport'; import Viewport from './viewport';
@ -138,10 +138,16 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
readonly emitter: EventEmitter = new EventEmitter(); readonly emitter: EventEmitter = new EventEmitter();
/**
*
*/
autoRender = true;
constructor(project: Project) { constructor(project: Project) {
this.project = project; this.project = project;
this.designer = project?.designer; this.designer = project?.designer;
this.scroller = this.designer.createScroller(this.viewport); this.scroller = this.designer.createScroller(this.viewport);
this.autoRender = engineConfig.get('disableAutoRender') !== true;
} }
get currentDocument() { get currentDocument() {

View File

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

View File

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

View File

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