mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 16:00:51 +00:00
fix: Fix the issue of abnormal runtime refresh on the overview page (#11106)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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 +
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user