This commit is contained in:
hyx
2022-03-21 14:56:39 +08:00
6 changed files with 65 additions and 63 deletions

View File

@@ -92,13 +92,13 @@
<script>
import { api, getData } from '@/utils/api'
import { eventSeverityColor,unitTypes ,topDomain} from '@/utils/constants'
import { eventSeverityColor, unitTypes } from '@/utils/constants'
import { getSecond } from '@/utils/date-util'
import { get } from '@/utils/http'
import * as echarts from 'echarts'
import { markRaw } from 'vue'
import { metricOption } from '@/views/detections/options/detectionOptions'
import { sortBy,reverseSortBy } from '@/utils/tools'
import { sortBy, reverseSortBy, computeSecondaryDomain } from '@/utils/tools'
export default {
name: 'DetectionPerformanceEventDomainOverview',
props: {
@@ -135,35 +135,10 @@ export default {
}
return result || '-'
}
},
computeSecondaryDomain () {
return function (name) {
// 命中的顶级域名
let hitTopDomain = ''
// 同顶级域名比对
const hits = []
topDomain.forEach(td => {
const hitIndex = name.lastIndexOf(td)
if (hitIndex > -1 && hitIndex + td.length === name.length) {
hits.push(td)
}
})
if (hits.length > 0) {
hits.sort((a, b) => {
return b.split('.').length - a.split('.').length
})
hitTopDomain = hits[0]
} else {
const arr = name.split('.')
hitTopDomain = arr[arr.length - 1]
}
const index = name.lastIndexOf(hitTopDomain)
const preArr = name.substring(0, index).split('.')
return [preArr[preArr.length - 2], hitTopDomain].join('.')
}
}
},
methods: {
computeSecondaryDomain,
query () {
this.queryBasic().then(responses => {
responses && (this.basicInfo = responses)