From ad8b3de0190077e66f8a34d1fde8a630760a8f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Fri, 9 Dec 2022 15:45:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../charts2/charts/npm/NpmNetworkQuantity.vue | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/views/charts2/charts/npm/NpmNetworkQuantity.vue b/src/views/charts2/charts/npm/NpmNetworkQuantity.vue index 1726c9ae..d246fc12 100644 --- a/src/views/charts2/charts/npm/NpmNetworkQuantity.vue +++ b/src/views/charts2/charts/npm/NpmNetworkQuantity.vue @@ -57,7 +57,7 @@ export default { }, watch: { timeFilter: { - handler (n) { + handler () { this.npmNetworkCycleData = [] this.npmNetworkLastCycleData = [] this.npmNetworkCycleQuery() @@ -79,9 +79,9 @@ export default { endTime: getSecond(this.timeFilter.endTime), cycle: 0 } - if (this.tabIndex == 0) { + if (this.tabIndex === 0) { this.side = 'client' - } else if (this.tabIndex == 1) { + } else if (this.tabIndex === 1) { this.side = 'server' } if (condition && (typeof condition !== 'object') && type) { @@ -126,6 +126,7 @@ export default { } this.npmNetworkLastCycleQuery(url, params) }).catch(e => { + console.error(e) this.toggleLoading(false) }) } else { @@ -136,6 +137,8 @@ export default { const packetPercent = get(api.npm.overview.packetRetransPercent, params) this.toggleLoading(true) Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => { + // 状态为200的,赋值接口数据,不为200的传入报错提示message, + // 传给子组件SingleValue,再进行error处理,注:error处理不在此处处理 this.npmNetworkCycleData = [] res.forEach(t => { if (t.code === 200) { @@ -177,18 +180,10 @@ export default { } else { this.npmNetworkLastCycleData = [res] } - const timer = null - if (timer) { - clearTimeout(timer) - } this.timer1 = setTimeout(() => { this.npmNetworkQuantity(this.npmNetworkCycleData, this.npmNetworkLastCycleData, 0) }, 300) }).catch((e) => { - const timer = null - if (timer) { - clearTimeout(timer) - } this.npmNetworkLastCycleData = [e] this.timer2 = setTimeout(() => { this.npmNetworkQuantity(this.npmNetworkCycleData, this.npmNetworkLastCycleData, 0) @@ -204,7 +199,9 @@ export default { const packetPercent = get(api.npm.overview.packetRetransPercent, params) this.toggleLoading(true) Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => { - res.forEach((t, i) => { + // 状态为200的,赋值接口数据,不为200的保留报错提示message, + // 传给子组件SingleValue,再进行error处理,注:error处理不在此处处理 + res.forEach(t => { if (t.code === 200) { this.npmNetworkLastCycleData.push(t.data.result) } else { @@ -215,7 +212,7 @@ export default { }).catch((e) => { // todo 此处的e可能为数组 if (e instanceof Array) { - e.forEach((t, i) => { + e.forEach(t => { this.npmNetworkLastCycleData.push(t) this.npmNetworkQuantity(this.npmNetworkCycleData, this.npmNetworkLastCycleData, 1) })