mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
feat: 支持 visionSettings.enableFilterReducerInRenderStage 配置项
This commit is contained in:
parent
79d0c33109
commit
277a18564a
@ -147,7 +147,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
this.project = project;
|
||||
this.designer = project?.designer;
|
||||
this.scroller = this.designer.createScroller(this.viewport);
|
||||
this.autoRender = engineConfig.get('disableAutoRender') !== true;
|
||||
this.autoRender = !engineConfig.get('disableAutoRender', false);
|
||||
}
|
||||
|
||||
get currentDocument() {
|
||||
|
||||
@ -530,7 +530,7 @@ export class Designer {
|
||||
|
||||
return reducers.reduce((xprops, reducer) => {
|
||||
try {
|
||||
return reducer(xprops, node);
|
||||
return reducer(xprops, node, { stage });
|
||||
} catch (e) {
|
||||
// todo: add log
|
||||
console.warn(e);
|
||||
@ -557,4 +557,5 @@ export class Designer {
|
||||
}
|
||||
}
|
||||
|
||||
export type PropsReducer = (props: CompositeObject, node: Node) => CompositeObject;
|
||||
export type PropsReducerContext = { stage: TransformStage };
|
||||
export type PropsReducer = (props: CompositeObject, node: Node, ctx?: PropsReducerContext) => CompositeObject;
|
||||
|
||||
@ -166,19 +166,19 @@ interface EngineOptions {
|
||||
*/
|
||||
enableCondition?: boolean;
|
||||
/**
|
||||
* 设计模式,live 模式将会实时展示变量值
|
||||
* 设计模式,live 模式将会实时展示变量值,默认值:'design'
|
||||
*/
|
||||
designMode?: 'design' | 'live';
|
||||
/**
|
||||
* 设备类型
|
||||
* 设备类型,默认值:'default'
|
||||
*/
|
||||
device?: 'default' | 'mobile' | string;
|
||||
/**
|
||||
* 语言
|
||||
* 语言,默认值:'zh_CN'
|
||||
*/
|
||||
locale?: string;
|
||||
/**
|
||||
* 渲染器类型
|
||||
* 渲染器类型,默认值:'react'
|
||||
*/
|
||||
renderEnv?: 'react' | 'rax' | string;
|
||||
/**
|
||||
@ -188,23 +188,24 @@ interface EngineOptions {
|
||||
transform: (originalDevice: string) => string;
|
||||
};
|
||||
/**
|
||||
* 开启拖拽组件时,即将被放入的容器是否有视觉反馈
|
||||
* 开启拖拽组件时,即将被放入的容器是否有视觉反馈,默认值:false
|
||||
*/
|
||||
enableReactiveContainer?: boolean;
|
||||
/**
|
||||
* 关闭画布自动渲染,在资产包多重异步加载的场景有效
|
||||
* 关闭画布自动渲染,在资产包多重异步加载的场景有效,默认值:false
|
||||
*/
|
||||
disableAutoRender?: boolean;
|
||||
/**
|
||||
* Vision-polyfill settings
|
||||
*/
|
||||
visionSettings?: {
|
||||
// 是否禁用降级Reducer
|
||||
// 是否禁用降级 reducer,默认值:false
|
||||
disableCompatibleReducer?: boolean;
|
||||
// 是否开启在 render 阶段开启 filter reducer,默认值:false
|
||||
enableFilterReducerInRenderStage?: boolean;
|
||||
}
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export async function init(container?: Element, options?: EngineOptions) {
|
||||
let engineOptions = null;
|
||||
let engineContainer = null;
|
||||
|
||||
@ -7,6 +7,7 @@ export {
|
||||
IDesignerCabin,
|
||||
BuiltinSimulatorHost,
|
||||
TransformStage,
|
||||
PropsReducerContext,
|
||||
} from '@ali/lowcode-designer';
|
||||
|
||||
// 这样做的目的是为了去除 Node / DocumentModel 等的值属性,仅保留类型属性
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
import logger from '@ali/vu-logger';
|
||||
import { Node, PropsReducerContext, designerCabin, engineConfig } from '@ali/lowcode-engine';
|
||||
import { hasOwnProperty } from '@ali/lowcode-utils';
|
||||
import { Node } from '@ali/lowcode-designer';
|
||||
const { TransformStage } = designerCabin;
|
||||
|
||||
export function filterReducer(props: any, node: Node): any {
|
||||
export function filterReducer(props: any, node: Node, ctx: PropsReducerContext): any {
|
||||
// 老的 vision 逻辑是 render 阶段不走 filter 逻辑
|
||||
if (ctx.stage === TransformStage.Render && !engineConfig.get('visionSettings.enableFilterReducerInRenderStage', false)) {
|
||||
return props;
|
||||
}
|
||||
const filters = node.componentMeta.getMetadata().experimental?.filters;
|
||||
if (filters && filters.length) {
|
||||
const newProps = { ...props };
|
||||
|
||||
@ -38,6 +38,7 @@ designer.addPropsReducer(initNodeReducer, TransformStage.Init);
|
||||
designer.addPropsReducer(liveLifecycleReducer, TransformStage.Render);
|
||||
|
||||
designer.addPropsReducer(filterReducer, TransformStage.Save);
|
||||
designer.addPropsReducer(filterReducer, TransformStage.Render);
|
||||
|
||||
// FIXME: Dirty fix, will remove this reducer
|
||||
designer.addPropsReducer(compatibleReducer, TransformStage.Save);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user