fix: 处理 JSExpreesion 的 i18n 场景

This commit is contained in:
力皓 2020-10-12 11:00:57 +08:00
parent 75fc3c6539
commit 9b87407596
2 changed files with 6 additions and 8 deletions

View File

@ -13,6 +13,7 @@ import { Skeleton, SettingsPrimaryPane, registerDefaults } from '@ali/lowcode-ed
import { deepValueParser } from './deep-value-parser';
import { liveEditingRule, liveEditingSaveHander } from './vc-live-editing';
import { isVariable } from './utils';
export const editor = new Editor();
globalContext.register(editor, Editor);
@ -36,10 +37,6 @@ interface Variable {
value: any;
}
function isVariable(obj: any): obj is Variable {
return obj && obj.type === 'variable';
}
function upgradePropsReducer(props: any) {
if (!props || !isPlainObject(props)) {
return props;
@ -123,9 +120,11 @@ designer.addPropsReducer((props, node) => {
if (ov === undefined && v !== undefined) {
newProps[item.name] = v;
}
// 兼容 props 中的属性为 i18n 类型,但是仅提供了一个
// 兼容 props 中的属性为 i18n 类型,但是仅提供了一个字符串,非变量绑定
if (isUseI18NSetter(node.componentMeta.prototype, item.name) &&
!isI18NObject(ov) && !isVariable(ov)) {
!isI18NObject(ov) &&
!isJSExpression(ov) &&
!isVariable(ov)) {
newProps[item.name] = v;
}
} catch (e) {

View File

@ -517,8 +517,7 @@ class ComponentCreator extends React.Component<{ schema: any; propsMap: any, com
if (this.isModal) {
return null;
}
const { schema, propsMap } = this.props;
const componentsMap = this.props.componentsMap;
const { schema, propsMap, componentsMap } = this.props;
const ComponentClass = componentsMap[schema.componentName];
if (!ComponentClass) {
return null;