From fe31bf05798ec3059ec4914566cf8e7c7654ecee Mon Sep 17 00:00:00 2001 From: tk Date: Wed, 18 Jun 2025 16:26:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20=E7=9B=B8?= =?UTF-8?q?=E5=AF=B9=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [skip ci] --- assets/res/NetAdmin.Fields.ln | 2 +- package.json | 2 +- .../NetAdmin.Infrastructure/Enums/Genders.cs | 4 +- src/frontend/admin/package.json | 9 ++-- src/frontend/admin/src/locales/lang/en.js | 10 ++-- src/frontend/admin/src/locales/lang/zh-cn.js | 10 ++-- src/frontend/admin/src/utils/tool.js | 52 ++++++++++++------- 7 files changed, 54 insertions(+), 35 deletions(-) diff --git a/assets/res/NetAdmin.Fields.ln b/assets/res/NetAdmin.Fields.ln index 160b779e..f4dc532f 100644 --- a/assets/res/NetAdmin.Fields.ln +++ b/assets/res/NetAdmin.Fields.ln @@ -17,7 +17,7 @@ 以什么结束 作业名称 作业状态 -保密 +密 信息 倒序排序 全部数据 diff --git a/package.json b/package.json index 514fcae4..56623bf0 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/backend/NetAdmin/NetAdmin.Infrastructure/Enums/Genders.cs b/src/backend/NetAdmin/NetAdmin.Infrastructure/Enums/Genders.cs index 1b25dc1d..374a0572 100644 --- a/src/backend/NetAdmin/NetAdmin.Infrastructure/Enums/Genders.cs +++ b/src/backend/NetAdmin/NetAdmin.Infrastructure/Enums/Genders.cs @@ -23,8 +23,8 @@ public enum Genders , /// - /// 保密 + /// 密 /// - [ResourceDescription(nameof(Ln.保密))] + [ResourceDescription(nameof(Ln.密))] Secrecy = 3 } \ No newline at end of file diff --git a/src/frontend/admin/package.json b/src/frontend/admin/package.json index 86b4740a..6050b930 100644 --- a/src/frontend/admin/package.json +++ b/src/frontend/admin/package.json @@ -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": [ diff --git a/src/frontend/admin/src/locales/lang/en.js b/src/frontend/admin/src/locales/lang/en.js index 7ac26441..79394a4c 100644 --- a/src/frontend/admin/src/locales/lang/en.js +++ b/src/frontend/admin/src/locales/lang/en.js @@ -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', diff --git a/src/frontend/admin/src/locales/lang/zh-cn.js b/src/frontend/admin/src/locales/lang/zh-cn.js index e57b55c6..e45247a8 100644 --- a/src/frontend/admin/src/locales/lang/zh-cn.js +++ b/src/frontend/admin/src/locales/lang/zh-cn.js @@ -564,10 +564,12 @@ export default { 外部组件: '外部组件', 至今: '至今', 未发现新的异常作业: '未发现新的异常作业', - 刚刚: '刚刚', - '{n} 天前': '{n} 天前', - '{n} 分钟前': '{n} 分钟前', - '{n} 小时前': '{n} 小时前', + '{n} 秒': '{n} 秒', + '{n} 分钟': '{n} 分钟', + '{n} 小时': '{n} 小时', + '{n} 天': '{n} 天', + 前: '前', + 后: '后', 下次执行: '下次执行', 成功率: '成功率', 总数: '总数', diff --git a/src/frontend/admin/src/utils/tool.js b/src/frontend/admin/src/utils/tool.js index 2cd22b15..42cd7fcd 100644 --- a/src/frontend/admin/src/utils/tool.js +++ b/src/frontend/admin/src/utils/tool.js @@ -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('前')}` }, }