From f434716ac13e5d954d9b0e48d71b9420873648fd Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Mon, 21 Mar 2022 11:56:54 +0800 Subject: [PATCH] =?UTF-8?q?CN-402=20fix:=20=E9=83=A8=E5=88=86=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/tools.js | 27 +++++++++++++++- ...etectionPerformanceEventDomainOverview.vue | 31 ++----------------- .../entityList/detailOverview/App.vue | 16 +++++----- .../entityList/detailOverview/Domain.vue | 14 ++++----- .../entityList/detailOverview/Ip.vue | 20 ++++++------ .../detailOverview/entityDetailMixin.js | 4 +-- 6 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/utils/tools.js b/src/utils/tools.js index 110641d7..c7f94b24 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -1,7 +1,7 @@ import { ElMessageBox, ElMessage } from 'element-plus' import i18n from '@/i18n' import _ from 'lodash' -import { storageKey, iso36112 } from '@/utils/constants' +import { storageKey, iso36112, topDomain } from '@/utils/constants' import { getIso36112JsonData } from '@/utils/api' import { format } from 'echarts' import router from '@/router' @@ -606,6 +606,31 @@ export function copyValue (item) { ElMessage.success(i18n.global.t('tip.copySuccess')) } +export function computeSecondaryDomain (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('.') +} + export function getCurrentRoute () { return router.currentRoute && router.currentRoute.path } diff --git a/src/views/detections/overview/DetectionPerformanceEventDomainOverview.vue b/src/views/detections/overview/DetectionPerformanceEventDomainOverview.vue index 469d0eaf..9f283c4b 100644 --- a/src/views/detections/overview/DetectionPerformanceEventDomainOverview.vue +++ b/src/views/detections/overview/DetectionPerformanceEventDomainOverview.vue @@ -92,12 +92,12 @@