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

View File

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