fix: Fix the issue of abnormal runtime refresh on the overview page (#11106)

This commit is contained in:
ssongliu
2025-11-27 10:37:24 +00:00
committed by GitHub
parent b2803f574b
commit 8ccf1fcbf3
3 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -180,7 +180,7 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d
var currentInfo dto.DashboardCurrent
hostInfo, _ := psutil.HOST.GetHostInfo(false)
currentInfo.Uptime = hostInfo.Uptime
currentInfo.TimeSinceUptime = time.Now().Add(-time.Duration(hostInfo.Uptime) * time.Second).Format(constant.DateTimeLayout)
currentInfo.TimeSinceUptime = time.Unix(int64(hostInfo.BootTime), 0).Format(constant.DateTimeLayout)
currentInfo.Procs = hostInfo.Procs
currentInfo.CPUTotal, _ = psutil.CPUInfo.GetLogicalCores(false)
+5 -2
View File
@@ -56,14 +56,17 @@ export function getBrowserLang() {
return defaultBrowserLang;
}
export function loadUpTime(uptime: number) {
export function loadUpTime(timeSince: string) {
const targetTime = new Date(timeSince);
const currentTime = new Date();
const uptime = (currentTime.getTime() - targetTime.getTime()) / 1000;
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 seconds = Math.floor(uptime % 60);
if (days !== 0) {
return (
days +
+2 -2
View File
@@ -261,7 +261,7 @@
<template #label>
<span class="system-label">{{ $t('home.runningTime') }}</span>
</template>
{{ loadUpTime(currentInfo.uptime) }}
{{ loadUpTime(currentInfo.timeSinceUptime) }}
</el-descriptions-item>
</el-descriptions>
</el-scrollbar>
@@ -689,7 +689,7 @@ const handleCopy = () => {
'\n' +
i18n.global.t('home.runningTime') +
': ' +
loadUpTime(currentInfo.value.uptime) +
loadUpTime(currentInfo.value.timeSinceUptime) +
'\n';
copyText(content);
};