CN-1415 fix: 建议Entity列表页增加Search History用于查看和使用历史搜索条件

This commit is contained in:
刘洪洪
2023-11-07 18:36:01 +08:00
parent 36c3db5dee
commit c89397da97
6 changed files with 169 additions and 34 deletions

View File

@@ -1403,3 +1403,22 @@ export const myHighLight = {
}
}
}
export const changeTimeByDate = (date) => {
if (date) {
const nowDate = Date.now()
const oldDate = Date.parse(date)
const diff = Math.floor((nowDate - oldDate) / 1000)
if (diff < 60) {
return 60 + i18n.global.t('entity.search.secondsAgo')
} else if (diff >= 60 && diff < 3600) {
const minutes = Math.floor(diff / 60)
return minutes === 1 ? `${minutes} ${i18n.global.t('entity.search.minuteAgo')}` : `${minutes} ${i18n.global.t('entity.search.minutesAgo')}`
} else if (diff >= 3600 && diff < 86400) {
const hours = Math.floor(diff / 3600)
return hours === 1 ? `${hours} ${i18n.global.t('entity.search.hourAgo')}` : `${hours} ${i18n.global.t('entity.search.hoursAgo')}`
} else {
return new Date(oldDate)
}
}
}