From 2bd18a18eaec7b307368f44e8e71f5704fa9ef0d Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Mon, 28 Feb 2022 15:24:47 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20detection=E5=B7=A6=E4=BE=A7=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E6=A0=B7=E5=BC=8F=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/unit-convert.js | 4 ++++ src/views/detections/Index.vue | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/unit-convert.js b/src/utils/unit-convert.js index 92a6ee6a..fcd09e3c 100644 --- a/src/utils/unit-convert.js +++ b/src/utils/unit-convert.js @@ -1,4 +1,5 @@ import { unitTypes } from '@/utils/constants' +import _ from 'lodash' const numberUnit = ['', 'K', 'M', 'G', 'T', 'P', 'E'] const byteUnit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'] @@ -35,6 +36,9 @@ export function byteUnitConvert (value, sourceUnit = 'B', targetUnit, dot = 2) { } /* 时间单位转换,例如将ms转为h */ export function timeUnitFormatter (time, sourceUnit = 'ms', targetUnit, dot = 2) { + if (!_.isNumber(time) || time === 0) { + return [0, sourceUnit] + } let sourceIndex = -1 let targetIndex = -1 timeUnit.forEach((t, i) => { diff --git a/src/views/detections/Index.vue b/src/views/detections/Index.vue index 63e71644..483e5bbc 100644 --- a/src/views/detections/Index.vue +++ b/src/views/detections/Index.vue @@ -15,7 +15,7 @@