From 28f487aff6fcae433b2a3dcf47d0d52c0d68fe13 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Mon, 23 Oct 2023 19:16:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=BB=E6=9C=BA=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=A4=A9=E6=97=B6?= =?UTF-8?q?=E5=88=86=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/locales/en-US.ts | 10 ++++++++++ src/i18n/locales/zh-CN.ts | 11 +++++++++++ src/views/monitor/system/info.vue | 31 +++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index a54a1e26..938e26ee 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -42,6 +42,16 @@ export default { }, rowId: 'RowID', operate: 'Operate', + units: { + second: 'Second', + minute: 'Minute', + hour: 'Hour', + day: 'Day', + week: 'Week', + month: 'Month', + year: 'Year', + core: 'Core', + } }, // 全局页脚 diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 8fee6b01..7fc19750 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -42,6 +42,17 @@ export default { }, rowId: '记录编号', operate: '操作', + units: { + second: '秒', + minute: '分钟', + hour: '小时', + day: '天', + week: '周', + month: '月', + year: '年', + time: '次', + core: '核', + } }, // 全局页脚 diff --git a/src/views/monitor/system/info.vue b/src/views/monitor/system/info.vue index 1fc6f215..47af7681 100644 --- a/src/views/monitor/system/info.vue +++ b/src/views/monitor/system/info.vue @@ -4,6 +4,8 @@ import { PageContainer } from '@ant-design-vue/pro-layout'; import { ColumnsType } from 'ant-design-vue/lib/table'; import { getSystemInfo } from '@/api/monitor/system'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; +import useI18n from '@/hooks/useI18n'; +const { t } = useI18n(); /**加载状态 */ let loading = ref(true); @@ -66,6 +68,31 @@ let server: ServerType = reactive({ time: {}, }); +function loadUpTime(uptime: string | number) { + if (typeof uptime === 'string') { + return uptime; + } + if (uptime <= 0) { + return '-'; + } + let days = Math.floor(uptime / 86400); + let hours = Math.floor((uptime % 86400) / 3600); + let minutes = Math.floor((uptime % 3600) / 60); + let seconds = uptime % 60; + let strArr: string[] = []; + if (days !== 0) { + strArr.push(`${days}${t('common.units.day')}`); + } + if (hours !== 0) { + strArr.push(`${hours}${t('common.units.hour')}`); + } + if (minutes !== 0) { + strArr.push(`${minutes}${t('common.units.minute')}`); + } + strArr.push(`${seconds}${t('common.units.second')}`); + return strArr.join(' '); +} + onMounted(() => { getSystemInfo().then(res => { if (res.code === RESULT_CODE_SUCCESS && res.data) { @@ -120,9 +147,9 @@ onMounted(() => { {{ server.system.hostname }} - + - {{ server.system.bootTime }} + {{ loadUpTime(server.system.bootTime) }}