feat: 基础本地化支持与通用键补充(useConfirm/useChartConfig/format/apiStats 回退 + common.time/errors 等 i18n 键)

This commit is contained in:
Wangnov
2025-09-10 18:04:09 +08:00
parent 97b94eeff9
commit 5f5826ce56
7 changed files with 1274 additions and 30 deletions

View File

@@ -37,7 +37,9 @@ export function formatDate(date, format = 'YYYY-MM-DD HH:mm:ss') {
.replace('ss', seconds)
}
// 相对时间格式化
// 相对时间格式化(使用 i18n
import i18n from '@/i18n'
export function formatRelativeTime(date) {
if (!date) return ''
@@ -50,13 +52,13 @@ export function formatRelativeTime(date) {
const diffDays = Math.floor(diffHours / 24)
if (diffDays > 0) {
return `${diffDays}天前`
return i18n.global.t('common.time.daysAgo', { days: diffDays })
} else if (diffHours > 0) {
return `${diffHours}小时前`
return i18n.global.t('common.time.hoursAgo', { hours: diffHours })
} else if (diffMins > 0) {
return `${diffMins}分钟前`
return i18n.global.t('common.time.minutesAgo', { minutes: diffMins })
} else {
return '刚刚'
return i18n.global.t('common.time.justNow')
}
}