diff --git a/src/components/device-page/device-card/history-diag-card/device-status-history-diag-card.vue b/src/components/device-page/device-card/history-diag-card/device-status-history-diag-card.vue index 7140852..efab1e1 100644 --- a/src/components/device-page/device-card/history-diag-card/device-status-history-diag-card.vue +++ b/src/components/device-page/device-card/history-diag-card/device-status-history-diag-card.vue @@ -83,6 +83,14 @@ const { mutate: getDeviceIcmpLogList, isPending } = useMutation({ const timelineItems = computed(() => { const items: TimelineItemProps[] = []; + if (icmpLogList.value.length === 0) { + const { deviceStatus } = ndmDevice.value; + const type: TimelineItemProps['type'] = deviceStatus === '10' ? 'success' : deviceStatus === '20' ? 'error' : 'warning'; + const title = deviceStatus === '10' ? '在线' : deviceStatus === '20' ? '离线' : '未知'; + const content = '至今' + (deviceStatus === '10' ? '在线' : deviceStatus === '20' ? '离线' : '未知'); + items.push({ type, title, content }); + return items; + } let prevIcmpLog = predecessorItem.value; for (const icmpLog of icmpLogList.value) { const { deviceStatus, createdTime } = icmpLog; @@ -90,12 +98,7 @@ const timelineItems = computed(() => { const title = deviceStatus === '10' ? '在线' : deviceStatus === '20' ? '离线' : '未知'; const content = `持续时长:${prevIcmpLog ? formatDuration(createdTime, prevIcmpLog.createdTime) : '至今'}`; const time = createdTime; - items.push({ - type, - title, - content, - time, - }); + items.push({ type, title, content, time }); prevIcmpLog = icmpLog; } return items;