fix: 修复NetworkOverviewLine的eslint报警提示

This commit is contained in:
刘洪洪
2023-03-02 18:36:02 +08:00
parent 04062195e2
commit fdb4ec5cf5

View File

@@ -122,12 +122,66 @@ export default {
} }
], ],
tabsTemplate: [ tabsTemplate: [
{ analysis: {}, name: 'network.total', class: 'total', show: true, invertTab: true, positioning: 0, data: [], unitType: '' }, {
{ analysis: {}, name: 'network.inbound', class: 'inbound', show: true, invertTab: true, positioning: 1, data: [], unitType: '' }, analysis: {},
{ analysis: {}, name: 'network.outbound', class: 'outbound', show: true, invertTab: true, positioning: 2, data: [], unitType: '' }, name: 'network.total',
{ analysis: {}, name: 'network.internal', class: 'internal', show: true, invertTab: true, positioning: 3, data: [], unitType: '' }, class: 'total',
{ analysis: {}, name: 'network.through', class: 'through', show: true, invertTab: true, positioning: 4, data: [], unitType: '' }, show: true,
{ analysis: {}, name: 'network.other', class: 'other', show: true, invertTab: true, positioning: 5, data: [], unitType: '' } invertTab: true,
positioning: 0,
data: [],
unitType: ''
},
{
analysis: {},
name: 'network.inbound',
class: 'inbound',
show: true,
invertTab: true,
positioning: 1,
data: [],
unitType: ''
},
{
analysis: {},
name: 'network.outbound',
class: 'outbound',
show: true,
invertTab: true,
positioning: 2,
data: [],
unitType: ''
},
{
analysis: {},
name: 'network.internal',
class: 'internal',
show: true,
invertTab: true,
positioning: 3,
data: [],
unitType: ''
},
{
analysis: {},
name: 'network.through',
class: 'through',
show: true,
invertTab: true,
positioning: 4,
data: [],
unitType: ''
},
{
analysis: {},
name: 'network.other',
class: 'other',
show: true,
invertTab: true,
positioning: 5,
data: [],
unitType: ''
}
], ],
tabs: [], tabs: [],
unitConvert, unitConvert,
@@ -225,25 +279,25 @@ export default {
/** /**
* 初始化echartsdom用于右键点击返回框选 * 初始化echartsdom用于右键点击返回框选
*/ */
domInit () { // domInit () {
const self = this // const self = this
// 去掉默认的contextmenu事件否则会和右键事件同时出现。 // // 去掉默认的contextmenu事件否则会和右键事件同时出现。
document.oncontextmenu = function (e) { // document.oncontextmenu = function (e) {
e.preventDefault() // e.preventDefault()
} // }
document.getElementById('overviewLineChart').onmousedown = function (e) { // document.getElementById('overviewLineChart').onmousedown = function (e) {
// e.button: 0左键1滚轮2右键 // // e.button: 0左键1滚轮2右键
if (e.button === 2) { // if (e.button === 2) {
self.myChart.dispatchAction({ // self.myChart.dispatchAction({
type: 'brush', // type: 'brush',
areas: [] // 删除选框 // areas: [] // 删除选框
}) // })
self.mouseDownFlag = true // self.mouseDownFlag = true
document.getElementById('brushBtn').style.left = e.layerX + 'px' // document.getElementById('brushBtn').style.left = e.layerX + 'px'
document.getElementById('brushBtn').style.top = e.layerY + 74 + 'px' // document.getElementById('brushBtn').style.top = e.layerY + 74 + 'px'
} // }
} // }
}, // },
echartsInit (echartsData, show) { echartsInit (echartsData, show) {
// echarts内容在单元测试时不执行 // echarts内容在单元测试时不执行
if (!this.isUnitTesting) { if (!this.isUnitTesting) {
@@ -262,10 +316,10 @@ export default {
return { return {
...chartOption, ...chartOption,
name: t.name, name: t.name,
type: "line", type: 'line',
showSymbol: false, showSymbol: false,
smooth: true, smooth: true,
symbol: "circle", symbol: 'circle',
lineStyle: { lineStyle: {
color: chartColor3[t.positioning], color: chartColor3[t.positioning],
width: 1 width: 1
@@ -479,7 +533,11 @@ export default {
}, },
handleActiveBar () { handleActiveBar () {
if (document.querySelector('.network .line-value-tabs.is-active')) { if (document.querySelector('.network .line-value-tabs.is-active')) {
const { offsetLeft, clientWidth, clientLeft } = document.querySelector('.network .line-value-tabs.is-active') const {
offsetLeft,
clientWidth,
clientLeft
} = document.querySelector('.network .line-value-tabs.is-active')
const activeBar = document.querySelector('.network .line-value-active') const activeBar = document.querySelector('.network .line-value-active')
activeBar.style.cssText += `width: ${clientWidth}px; left: ${offsetLeft + this.leftOffset + clientLeft}px;` activeBar.style.cssText += `width: ${clientWidth}px; left: ${offsetLeft + this.leftOffset + clientLeft}px;`
} }
@@ -500,19 +558,19 @@ export default {
if (!this.isUnitTesting) { if (!this.isUnitTesting) {
const chartOption = this.myChart.getOption() const chartOption = this.myChart.getOption()
if (this.lineRefer === 'Average' && this.showMarkLine) { if (this.lineRefer === 'Average' && this.showMarkLine) {
chartOption.series.forEach((t, i) => { chartOption.series.forEach((t) => {
if (t.name === echartsData[0].name) { if (t.name === echartsData[0].name) {
t.markLine.data = [{ yAxis: echartsData[0].analysis.avg }] t.markLine.data = [{ yAxis: echartsData[0].analysis.avg }]
} }
}) })
} else if (this.lineRefer === '95th Percentile' && this.showMarkLine) { } else if (this.lineRefer === '95th Percentile' && this.showMarkLine) {
chartOption.series.forEach((t, i) => { chartOption.series.forEach((t) => {
if (t.name === echartsData[0].name) { if (t.name === echartsData[0].name) {
t.markLine.data = [{ yAxis: echartsData[0].analysis.p95 }] t.markLine.data = [{ yAxis: echartsData[0].analysis.p95 }]
} }
}) })
} else if (this.lineRefer === 'Maximum' && this.showMarkLine) { } else if (this.lineRefer === 'Maximum' && this.showMarkLine) {
chartOption.series.forEach((t, i) => { chartOption.series.forEach((t) => {
if (t.name === echartsData[0].name) { if (t.name === echartsData[0].name) {
t.markLine.data = [{ yAxis: echartsData[0].analysis.max }] t.markLine.data = [{ yAxis: echartsData[0].analysis.max }]
} }
@@ -565,7 +623,9 @@ export default {
otherData[2] = 5 otherData[2] = 5
} }
} }
dataIntegrationArray.sort((a, b) => { return a[1] - b[1] }) dataIntegrationArray.sort((a, b) => {
return a[1] - b[1]
})
const sortIndex = dataIntegrationArray.findIndex(a => a[2] === index) const sortIndex = dataIntegrationArray.findIndex(a => a[2] === index)
return this.sizes[sortIndex] return this.sizes[sortIndex]
}, },
@@ -615,10 +675,10 @@ export default {
tabs[i].analysis = d.analysis tabs[i].analysis = d.analysis
}) })
let num = 0 let num = 0
let self = this const self = this
tabs.forEach(e => { tabs.forEach(e => {
e.unitType = type e.unitType = type
if (e.name !== 'network.total' && parseFloat(e.analysis.avg) == 0) { if (e.name !== 'network.total' && parseFloat(e.analysis.avg) === 0) {
e.show = false e.show = false
num += 1 num += 1
} else { } else {
@@ -650,28 +710,28 @@ export default {
if (!this.lineRefer) this.lineRefer = 'Average' if (!this.lineRefer) this.lineRefer = 'Average'
}) })
} }
}, }
/** /**
* 鼠标右键返回框选的时间范围 * 鼠标右键返回框选的时间范围
*/ */
backBrushHistory () { // backBrushHistory () {
this.myChart.dispatchAction({ // this.myChart.dispatchAction({
type: 'brush', // type: 'brush',
areas: [] // 删除选框 // areas: [] // 删除选框
}) // })
if (this.brushHistory.length > 0) { // if (this.brushHistory.length > 0) {
this.$store.commit('setRangeEchartsData', _.cloneDeep(this.brushHistory[0])) // this.$store.commit('setRangeEchartsData', _.cloneDeep(this.brushHistory[0]))
this.brushHistory.shift() // this.brushHistory.shift()
} // }
this.mouseDownFlag = false // this.mouseDownFlag = false
} // }
}, },
mounted () { mounted () {
// todo 初始化鼠标事件,开启右键返回 // todo 初始化鼠标事件,开启右键返回
// this.domInit() // this.domInit()
this.myChart = null this.myChart = null
this.chartOption = null this.chartOption = null
let self = this const self = this
self.timer = setTimeout(() => { self.timer = setTimeout(() => {
if (self.lineTab && self.metric !== 'Sessions/s') { if (self.lineTab && self.metric !== 'Sessions/s') {
const data = self.tabsTemplate.find(t => t.class === self.lineTab) const data = self.tabsTemplate.find(t => t.class === self.lineTab)