Skip to content

Commit 1c0f1a9

Browse files
committed
fix: Fix the issue of abnormal runtime refresh on the overview page
1 parent b2803f5 commit 1c0f1a9

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

agent/app/service/dashboard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d
180180
var currentInfo dto.DashboardCurrent
181181
hostInfo, _ := psutil.HOST.GetHostInfo(false)
182182
currentInfo.Uptime = hostInfo.Uptime
183-
currentInfo.TimeSinceUptime = time.Now().Add(-time.Duration(hostInfo.Uptime) * time.Second).Format(constant.DateTimeLayout)
183+
currentInfo.TimeSinceUptime = time.Unix(int64(hostInfo.BootTime), 0).Format(constant.DateTimeLayout)
184184
currentInfo.Procs = hostInfo.Procs
185185
currentInfo.CPUTotal, _ = psutil.CPUInfo.GetLogicalCores(false)
186186

frontend/src/utils/util.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ export function getBrowserLang() {
5656
return defaultBrowserLang;
5757
}
5858

59-
export function loadUpTime(uptime: number) {
59+
export function loadUpTime(timeSince: string) {
60+
const targetTime = new Date(timeSince);
61+
const currentTime = new Date();
62+
const uptime = (currentTime.getTime() - targetTime.getTime()) / 1000;
6063
if (uptime <= 0) {
6164
return '-';
6265
}
6366
let days = Math.floor(uptime / 86400);
6467
let hours = Math.floor((uptime % 86400) / 3600);
6568
let minutes = Math.floor((uptime % 3600) / 60);
66-
let seconds = uptime % 60;
69+
let seconds = Math.floor(uptime % 60);
6770
if (days !== 0) {
6871
return (
6972
days +

frontend/src/views/home/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
<template #label>
262262
<span class="system-label">{{ $t('home.runningTime') }}</span>
263263
</template>
264-
{{ loadUpTime(currentInfo.uptime) }}
264+
{{ loadUpTime(currentInfo.timeSinceUptime) }}
265265
</el-descriptions-item>
266266
</el-descriptions>
267267
</el-scrollbar>
@@ -689,7 +689,7 @@ const handleCopy = () => {
689689
'\n' +
690690
i18n.global.t('home.runningTime') +
691691
': ' +
692-
loadUpTime(currentInfo.value.uptime) +
692+
loadUpTime(currentInfo.value.timeSinceUptime) +
693693
'\n';
694694
copyText(content);
695695
};

frontend/src/views/home/status/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@
304304
<el-col :xs="6" :sm="6" :md="3" :lg="3" :xl="3" align="center" v-if="isShow('xpu', index)">
305305
<el-popover :hide-after="20" :teleported="false" :width="400" v-if="chartsOption[`xpu${index}`]">
306306
<el-descriptions :title="item.deviceName" direction="vertical" :column="4" size="small">
307-
<el-descriptions-item :label="$t('monitor.gpuUtil')">
307+
<el-descriptions-item :label="$t('monitor.memoryUtil')">
308308
{{ item.memoryUtil }}
309309
</el-descriptions-item>
310310
<el-descriptions-item :label="$t('monitor.temperature')">

0 commit comments

Comments
 (0)