From eb7886108261c0485219f66ac0e71b7f6a534197 Mon Sep 17 00:00:00 2001 From: zhangrenyuan <18990852002@163.com> Date: Thu, 22 Jan 2026 17:20:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BD=E9=99=85=E5=8C=96):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=97=B6=E9=97=B4=E5=B7=AE=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在utils/getMessage.js中实现时间差显示的国际化,并分别在zh-CN.js和en.js中添加对应的翻译文本 --- src/components/locales/lang/en.js | 5 +++++ src/components/locales/lang/zh-CN.js | 5 +++++ src/utils/getMessage.js | 7 ++++--- 3 files changed, 14 insertions(+), 3 deletions(-) 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')}` }