forked from FoundKeyGang/FoundKey
fix: nonblock-statement-body-position lint in time.vue
This commit is contained in:
parent
0965d3cbd9
commit
fd2028df48
1 changed files with 14 additions and 10 deletions
|
@ -36,22 +36,26 @@ let now = $ref(new Date());
|
||||||
const relative = $computed(() => {
|
const relative = $computed(() => {
|
||||||
const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/;
|
const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/;
|
||||||
|
|
||||||
if (ago >= 31536000)
|
if (ago >= 31536000) {
|
||||||
return i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() });
|
return i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() });
|
||||||
if (ago >= 2592000)
|
} else if (ago >= 2592000) {
|
||||||
return i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() });
|
return i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() });
|
||||||
if (ago >= 604800)
|
} else if (ago >= 604800) {
|
||||||
return i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() });
|
return i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() });
|
||||||
if (ago >= 86400)
|
} else if (ago >= 86400) {
|
||||||
return i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() });
|
return i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() });
|
||||||
|
}
|
||||||
|
|
||||||
// if the format is 'date', the relative date precision is no more than days ago
|
// if the format is 'date', the relative date precision is no more than days ago
|
||||||
if (props.format !== 'date' && ago >= 3600)
|
if (props.format !== 'date') {
|
||||||
|
if (ago >= 3600) {
|
||||||
return i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() });
|
return i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() });
|
||||||
if (props.format !== 'date' && ago >= 60)
|
} else if (ago >= 60) {
|
||||||
return i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() });
|
return i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() });
|
||||||
if (props.format !== 'date' && ago >= 10)
|
} else if (ago >= 10) {
|
||||||
return i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() });
|
return i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ago >= -5) {
|
if (ago >= -5) {
|
||||||
if (props.format === 'date') {
|
if (props.format === 'date') {
|
||||||
|
|
Loading…
Reference in a new issue