code refactor

This commit is contained in:
MaysWind
2020-12-22 00:44:34 +08:00
parent cb22bee25a
commit 6c4cce5601
6 changed files with 26 additions and 28 deletions
+13
View File
@@ -0,0 +1,13 @@
export default function ({i18n}, value, fieldName, defaultValue, translate) {
let content = defaultValue;
if (fieldName) {
content = value[fieldName];
}
if (translate && content) {
content = i18n.t(content);
}
return content;
}
-15
View File
@@ -1,15 +0,0 @@
export default function ({i18n}, value, fieldName, translate) {
let content = '';
if (fieldName) {
content = value[fieldName];
} else {
content = value;
}
if (translate) {
content = i18n.t(content);
}
return content;
}