fix: 🐛 用 isI18nData 判断 meta title

This commit is contained in:
YJSON 2020-07-15 21:16:18 +08:00
parent 927c8f22fd
commit 732bccffde

View File

@ -1,5 +1,5 @@
import { ComponentType, ReactElement } from 'react'; import { ComponentType, ReactElement } from 'react';
import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem } from '@ali/lowcode-types'; import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem, isI18nData } from '@ali/lowcode-types';
import { import {
ComponentMeta, ComponentMeta,
addBuiltinComponentAction, addBuiltinComponentAction,
@ -259,6 +259,7 @@ class Prototype {
} }
getTitle(currentLocale?: string) { getTitle(currentLocale?: string) {
if (isI18nData(this.meta.title)) {
if (currentLocale && this.meta.title[currentLocale]) { if (currentLocale && this.meta.title[currentLocale]) {
return this.meta.title[currentLocale]; return this.meta.title[currentLocale];
} }
@ -266,6 +267,7 @@ class Prototype {
if (this.meta.title && this.meta.title.type === 'i18n') { if (this.meta.title && this.meta.title.type === 'i18n') {
return this.meta.title[locale] || this.meta.title; return this.meta.title[locale] || this.meta.title;
} }
}
return this.meta.title; return this.meta.title;
} }