fix: 修复未对无数据情况做处理,导致单侧实例报错的问题

This commit is contained in:
刘洪洪
2023-09-06 17:05:38 +08:00
parent 25ae5afcb0
commit 3855a781c2
2 changed files with 14 additions and 9 deletions

View File

@@ -148,15 +148,20 @@ export default {
if (response.status === 200) { if (response.status === 200) {
this.showError = false this.showError = false
this.isNoData = res.data.result.length === 0 this.isNoData = res.data.result.length === 0
const data = { if (this.isNoData) {
establishLatencyMs: _.get(res.data.result[0], 'establishLatencyMs', null), this.linkTrafficListData = {}
httpResponseLatency: _.get(res.data.result[0], 'httpResponseLatency', null), this.linkTrafficListData.npmScore = '-'
sslConLatency: _.get(res.data.result[0], 'sslConLatency', null), } else {
tcpLostlenPercent: _.get(res.data.result[0], 'tcpLostlenPercent', null), const data = {
pktRetransPercent: _.get(res.data.result[0], 'pktRetransPercent', null) establishLatencyMs: _.get(res.data.result[0], 'establishLatencyMs', null),
httpResponseLatency: _.get(res.data.result[0], 'httpResponseLatency', null),
sslConLatency: _.get(res.data.result[0], 'sslConLatency', null),
tcpLostlenPercent: _.get(res.data.result[0], 'tcpLostlenPercent', null),
pktRetransPercent: _.get(res.data.result[0], 'pktRetransPercent', null)
}
this.linkTrafficListData = res.data.result[0]
this.linkTrafficListData.npmScore = computeScore(data)
} }
this.linkTrafficListData = res.data.result[0]
this.linkTrafficListData.npmScore = computeScore(data)
} else { } else {
this.showError = true this.showError = true
this.errorMsg = res.message this.errorMsg = res.message

View File

@@ -125,7 +125,7 @@ describe('views/charts2/charts/npm/NpmAppCategoryScore.vue测试', () => {
expect(textNode0.text()).toBe('6') expect(textNode0.text()).toBe('6')
expect(textNode1.text()).toBe('6') expect(textNode1.text()).toBe('6')
expect(textNode2.text()).toBe('-') expect(textNode2.text()).toBe('6')
// expect(textNode3.text()).toBe('-') // expect(textNode3.text()).toBe('-')
expect(textNode4.text()).toBe('5') expect(textNode4.text()).toBe('5')
expect(textNode5.text()).toBe('3') expect(textNode5.text()).toBe('3')