Merge branch 'feat/vision-reducer-disabled' into 'release/1.0.51'

feat: 新增vision engineconfig,支持禁用某些reducer

feat: 新增vision engineconfig,支持禁用某些reducer

See merge request !1273445
This commit is contained in:
力皓 2021-06-02 12:41:47 +08:00
commit 7d4496eac2
4 changed files with 19 additions and 3 deletions

View File

@ -21,6 +21,7 @@
"classnames": "^2.2.6",
"debug": "^4.1.1",
"intl-messageformat": "^9.3.1",
"lodash.get": "^4.4.2",
"power-di": "^2.2.4",
"react": "^16",
"react-dom": "^16.7.0",
@ -29,6 +30,7 @@
"devDependencies": {
"@alib/build-scripts": "^0.1.18",
"@types/classnames": "^2.2.7",
"@types/lodash.get": "^4.4.6",
"@types/node": "^13.7.1",
"@types/react": "^16",
"@types/react-dom": "^16",

View File

@ -1,3 +1,5 @@
import lodashGet from 'lodash.get';
export class EngineConfig {
private config: { [key: string]: any } = {};
@ -17,8 +19,8 @@ export class EngineConfig {
return this.config[key] !== undefined;
}
get(key: string): any {
return this.config[key];
get(key: string, defaultValue?: any): any {
return lodashGet(this.config, key, defaultValue);
}
set(key: string, value: any) {

View File

@ -195,6 +195,13 @@ interface EngineOptions {
*
*/
disableAutoRender?: boolean;
/**
* Vision-polyfill settings
*/
visionSettings?: {
// 是否禁用降级Reducer
disableCompatibleReducer?: boolean;
}
[key: string]: any;
}

View File

@ -3,8 +3,13 @@ import {
} from '@ali/lowcode-utils';
import { isJSExpression, isJSSlot } from '@ali/lowcode-types';
import { Node } from '@ali/lowcode-designer';
import { engineConfig } from '@ali/lowcode-editor-core';
export function compatibleReducer(props: any, node: Node): any {
// 如果禁用了降级reducer则不做处理
if (engineConfig.get('visionSettings.disableCompatibleReducer')) {
return props;
}
// 如果不是 vc 体系,不做这个兼容处理
if (!node.componentMeta.prototype) {
return props;
@ -27,7 +32,7 @@ export function compatibleReducer(props: any, node: Node): any {
},
};
}
if (isJSExpression(props) && !props.events) {
if (!props.events && isJSExpression(props)) {
return {
type: 'variable',
value: props.mock,