diff --git a/src/utils/constants.js b/src/utils/constants.js index 1a84d610..0ac17462 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -2489,6 +2489,7 @@ export const entityDetailTags = { } ] } +export const entityDefaultColor = 'rgb(119,131,145)' // 赛风3IP的type字段字典 export const psiphon3IpType = [ { diff --git a/src/utils/tools.js b/src/utils/tools.js index 36b225de..7ca03913 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -1356,3 +1356,18 @@ export function beforeRouterPush () { } store.commit('setRouterHistoryList', historyList) } + +/** + * 配置tag颜色,此为接口返回的颜色字段,color为rgb格式 + * @param color + * @returns {string} + */ +export function getTagColor (color) { + if (color) { + let backgroundColor = '' + if (color.indexOf('rgb(') > -1) { + backgroundColor = color.replace('rgb(', 'rgba(').replace(')', ',0.06)') + } + return `color: ${color};border-color: ${color};background-color: ${backgroundColor};` + } +} diff --git a/src/views/charts2/charts/entityDetail/EntityDetailBasicInfo.vue b/src/views/charts2/charts/entityDetail/EntityDetailBasicInfo.vue index cbd81b9d..24a5371a 100644 --- a/src/views/charts2/charts/entityDetail/EntityDetailBasicInfo.vue +++ b/src/views/charts2/charts/entityDetail/EntityDetailBasicInfo.vue @@ -32,7 +32,13 @@
@@ -55,9 +61,10 @@ import { entityType, entityDetailTags, psiphon3IpType, - riskLevelMapping + riskLevelMapping, + entityDefaultColor } from '@/utils/constants' -import { selectElementText, copySelectionText } from '@/utils/tools' +import { selectElementText, copySelectionText, getTagColor } from '@/utils/tools' import { ref } from 'vue' import i18n from '@/i18n' import { useRouter } from 'vue-router' @@ -84,6 +91,7 @@ export default { } }, methods: { + getTagColor, tagValueHandler (k, k2, value) { if (k === 'psiphon3Ip') { if (k2 === 'type') { @@ -120,7 +128,7 @@ export default { } }) if (_.isArray(res.data.userDefinedTags)) { - this.levelTwoTags = _.concat(this.levelTwoTags, res.data.userDefinedTags.map(tag => ({ value: tag.tagValue, type: 'normal' }))) + this.levelTwoTags = _.concat(this.levelTwoTags, res.data.userDefinedTags.map(tag => ({ value: tag.tagValue, color: tag.knowledgeBase ? tag.knowledgeBase.color : entityDefaultColor }))) } this.hideTagArea = _.isEmpty(this.levelTwoTags) this.$nextTick(() => { diff --git a/src/views/entityExplorer/entityGraph/GraphEntityDetail.vue b/src/views/entityExplorer/entityGraph/GraphEntityDetail.vue index e39e8b99..2ae565f1 100644 --- a/src/views/entityExplorer/entityGraph/GraphEntityDetail.vue +++ b/src/views/entityExplorer/entityGraph/GraphEntityDetail.vue @@ -86,7 +86,7 @@