mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 22:58:15 +00:00
feat: 支持 disableAutoRender 配置项
This commit is contained in:
parent
61f1c2ec5a
commit
719928a02c
@ -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() {
|
||||||
|
|||||||
@ -191,6 +191,10 @@ interface EngineOptions {
|
|||||||
* 开启拖拽组件时,即将被放入的容器是否有视觉反馈
|
* 开启拖拽组件时,即将被放入的容器是否有视觉反馈
|
||||||
*/
|
*/
|
||||||
enableReactiveContainer?: boolean;
|
enableReactiveContainer?: boolean;
|
||||||
|
/**
|
||||||
|
* 关闭画布自动渲染,在资产包多重异步加载的场景有效
|
||||||
|
*/
|
||||||
|
disableAutoRender?: boolean;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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 };
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user