mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-06-19 18:28:17 +08:00
refactor: ♻️ 相对时间显示
[skip ci]
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
以什么结束
|
||||
作业名称
|
||||
作业状态
|
||||
保密
|
||||
密
|
||||
信息
|
||||
倒序排序
|
||||
全部数据
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": "2.3.1",
|
||||
"devDependencies": {
|
||||
"cz-git": "^1.11.1",
|
||||
"cz-git": "^1.11.2",
|
||||
"commitizen": "^4.3.1",
|
||||
"prettier": "^3.5.3",
|
||||
"standard-version": "^9.5.0"
|
||||
|
@ -23,8 +23,8 @@ public enum Genders
|
||||
,
|
||||
|
||||
/// <summary>
|
||||
/// 保密
|
||||
/// 密
|
||||
/// </summary>
|
||||
[ResourceDescription<Ln>(nameof(Ln.保密))]
|
||||
[ResourceDescription<Ln>(nameof(Ln.密))]
|
||||
Secrecy = 3
|
||||
}
|
@ -12,10 +12,11 @@
|
||||
"@element-plus/icons-vue": "2.3.1",
|
||||
"ace-builds": "1.42.0",
|
||||
"aieditor": "1.3.9",
|
||||
"axios": "1.9.0",
|
||||
"axios": "1.10.0",
|
||||
"crypto-js": "4.2.0",
|
||||
"dayjs": "1.11.13",
|
||||
"echarts": "5.6.0",
|
||||
"element-plus": "2.10.1",
|
||||
"element-plus": "2.10.2",
|
||||
"json-bigint": "1.0.0",
|
||||
"markdown-it": "14.1.0",
|
||||
"markdown-it-emoji": "3.0.0",
|
||||
@ -23,7 +24,7 @@
|
||||
"sortablejs": "1.15.6",
|
||||
"vkbeautify": "0.99.3",
|
||||
"vue": "3.5.16",
|
||||
"vue-i18n": "11.1.5",
|
||||
"vue-i18n": "11.1.6",
|
||||
"vue-router": "4.5.1",
|
||||
"vue3-ace-editor": "2.2.4",
|
||||
"vue3-json-viewer": "2.4.0",
|
||||
@ -35,7 +36,7 @@
|
||||
"prettier": "3.5.3",
|
||||
"prettier-plugin-organize-attributes": "1.0.0",
|
||||
"sass": "1.89.2",
|
||||
"terser": "5.42.0",
|
||||
"terser": "5.43.0",
|
||||
"vite": "6.3.5"
|
||||
},
|
||||
"browserslist": [
|
||||
|
@ -566,10 +566,12 @@ export default {
|
||||
外部组件: 'External components',
|
||||
至今: 'Ever since',
|
||||
未发现新的异常作业: 'No new anomalous jobs were found',
|
||||
刚刚: 'Newly',
|
||||
'{n} 天前': '{n} days ago',
|
||||
'{n} 分钟前': '{n} minutes ago',
|
||||
'{n} 小时前': '{n} hours ago',
|
||||
'{n} 秒': '{n} seconds',
|
||||
'{n} 分钟': '{n} minutes',
|
||||
'{n} 小时': '{n} hours',
|
||||
'{n} 天': '{n} days',
|
||||
前: ' ago',
|
||||
后: ' after',
|
||||
下次执行: 'Next time',
|
||||
成功率: 'Success rate',
|
||||
总数: 'Total',
|
||||
|
@ -564,10 +564,12 @@ export default {
|
||||
外部组件: '外部组件',
|
||||
至今: '至今',
|
||||
未发现新的异常作业: '未发现新的异常作业',
|
||||
刚刚: '刚刚',
|
||||
'{n} 天前': '{n} 天前',
|
||||
'{n} 分钟前': '{n} 分钟前',
|
||||
'{n} 小时前': '{n} 小时前',
|
||||
'{n} 秒': '{n} 秒',
|
||||
'{n} 分钟': '{n} 分钟',
|
||||
'{n} 小时': '{n} 小时',
|
||||
'{n} 天': '{n} 天',
|
||||
前: '前',
|
||||
后: '后',
|
||||
下次执行: '下次执行',
|
||||
成功率: '成功率',
|
||||
总数: '总数',
|
||||
|
@ -1,6 +1,12 @@
|
||||
import CryptoJS from 'crypto-js'
|
||||
import sysConfig from '@/config'
|
||||
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
|
||||
// 扩展插件和语言设置
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
const tool = {}
|
||||
|
||||
tool.time = {
|
||||
@ -38,27 +44,35 @@ tool.time = {
|
||||
},
|
||||
//转换时间
|
||||
getFormatTime: function (_this, timestamp) {
|
||||
timestamp = new Date(timestamp)
|
||||
const now = this.getUnix()
|
||||
const today = this.getTodayUnix()
|
||||
//var year = this.getYearUnix();
|
||||
const timer = (now - timestamp) / 1000
|
||||
let tip
|
||||
if (!timestamp) return '--'
|
||||
|
||||
if (timer <= 0) {
|
||||
tip = _this.$t('刚刚')
|
||||
} else if (Math.floor(timer / 60) <= 0) {
|
||||
tip = _this.$t('刚刚')
|
||||
} else if (timer < 3600) {
|
||||
tip = _this.$t('{n} 分钟前', { n: Math.floor(timer / 60) })
|
||||
} else if (timer >= 3600 && (timestamp - today >= 0 || Math.floor(timer / 86400) <= 0)) {
|
||||
tip = _this.$t('{n} 小时前', { n: Math.floor(timer / 3600) })
|
||||
} else if (timer / 86400 <= 31) {
|
||||
tip = _this.$t('{n} 天前', { n: Math.floor(timer / 86400) })
|
||||
} else {
|
||||
tip = this.getLastDate(timestamp)
|
||||
const now = dayjs()
|
||||
const target = dayjs(timestamp)
|
||||
const diffSeconds = now.diff(target, 'second', true)
|
||||
const isFuture = diffSeconds < 0 // 是否未来时间
|
||||
const absDiff = Math.abs(diffSeconds) // 时间差绝对值
|
||||
|
||||
// 超过10天(10 * 24 * 60 * 60 秒)显示具体日期
|
||||
if (absDiff > 10 * 86400) {
|
||||
return target.format('YYYY-MM-DD')
|
||||
}
|
||||
return tip
|
||||
|
||||
let result = ''
|
||||
if (absDiff < 60) {
|
||||
// 1分钟内
|
||||
result = _this.$t(`{n} 秒`, { n: Math.floor(absDiff) })
|
||||
} else if (absDiff < 3600) {
|
||||
// 1小时内
|
||||
result = _this.$t(`{n} 分钟`, { n: Math.floor(absDiff / 60) })
|
||||
} else if (absDiff < 86400) {
|
||||
// 24小时内
|
||||
result = _this.$t(`{n} 小时`, { n: Math.floor(absDiff / 3600) })
|
||||
} else {
|
||||
// 10天内
|
||||
result = _this.$t(`{n} 天`, { n: Math.floor(absDiff / 86400) })
|
||||
}
|
||||
// 未来时间加“后”,过去时间加“前”
|
||||
return isFuture ? `${result}${_this.$t('后')}` : `${result}${_this.$t('前')}`
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user