diff --git a/src/components/locales/lang/en.js b/src/components/locales/lang/en.js index 3332c88..8bf6a24 100644 --- a/src/components/locales/lang/en.js +++ b/src/components/locales/lang/en.js @@ -1044,6 +1044,11 @@ export default { }, submitting: "Changing..." }, + difftime: { + minuteAgo: " mins ago", + hourAgo: " hours ago", + yesterday: "yesterday", + } }, // Cash Management diff --git a/src/components/locales/lang/zh-CN.js b/src/components/locales/lang/zh-CN.js index bdb8858..cdcf34e 100644 --- a/src/components/locales/lang/zh-CN.js +++ b/src/components/locales/lang/zh-CN.js @@ -1055,6 +1055,11 @@ export default { }, submitting: "修改中..." }, + difftime: { + minuteAgo: "分钟前", + hourAgo: "小时前", + yesterday: "昨天", + } }, // 现金管理 diff --git a/src/utils/getMessage.js b/src/utils/getMessage.js index 84d51e8..576d845 100644 --- a/src/utils/getMessage.js +++ b/src/utils/getMessage.js @@ -20,12 +20,13 @@ function formatTime(timeStr) { const diffHours = Math.floor(diffMins / 60); const diffDays = Math.floor(diffHours / 24); + const t = i18n.global.t if (diffHours < 1) { - return `${diffMins}分钟前` + return `${diffMins}${t('home.difftime.minuteAgo')}` } else if (diffDays < 1) { - return `${diffHours}小时前` + return `${diffHours}${t('home.difftime.hourAgo')}` } else if (diffDays === 1) { - return '昨天' + return t('home.difftime.yesterday') } else { return `${msgTime.getFullYear()}-${String(msgTime.getMonth() + 1).padStart(2, '0')}-${String(msgTime.getDate()).padStart(2, '0')}` }