fix: 修复关系图有时无法拓展的问题

This commit is contained in:
chenjinsong
2023-07-17 10:48:13 +08:00
parent 766b777bc6
commit f915c51254

View File

@@ -708,7 +708,7 @@ export default {
const domainNode = this.generatePrimaryNode({
id: 'domain-1',
parentId: rootNode.id,
label: this.$t('entity.graph.resolvedDomain'),
label: this.$t('entity.graph.resolveDomain'),
x: 260,
y: -150,
data: {
@@ -1140,7 +1140,7 @@ export default {
}
case 'domain': {
iconClass = 'cn-icon cn-icon-subdomain'
title = _this.$t('entity.graph.resolvedDomain')
title = _this.$t('entity.graph.resolveDomain')
break
}
case 'app': {
@@ -1246,12 +1246,13 @@ export default {
},
async expandDetailList (expandType, currentName) {
const currentNode = this.graphData.nodes.find(n => n.id === currentName)
console.info(currentNode)
// 如果存在primary node直接拓展
const _primaryNode = currentNode.data.childNodes ? currentNode.data.childNodes.find(n => n.data.type === expandType) : null
if (_primaryNode) {
await this.expandList(currentName, _primaryNode.id)
} else {
// 如果temp node删掉新增primary node再拓展
// 如果存在temp node删掉新增primary node再拓展
const tempNode = this.graphData.nodes.find(n => n.nodeType === 'temp' && n.data.sourceName === currentName && n.data.type === expandType)
if (tempNode) {
// 先清除此temp node和temp edge
@@ -1261,16 +1262,42 @@ export default {
this.graphData.edges = this.graphData.edges.filter(e => {
return e.target !== tempNode.id
})
}
let label = ''
let isSubdomain = false
let count = 0
switch (expandType) {
case 'ip': {
count = _.get(currentNode.data, 'relatedEntityCount.ip.total', 0)
label = `${this.$t('entities.graph.resolveIp')}(${count})`
break
}
case 'domain': {
if (currentNode.data.type === 'domain') {
count = _.get(currentNode.data, 'relatedEntityCount.subdomain.total', 0)
label = `${this.$t('entities.subdomain')}(${count})`
isSubdomain = true
} else {
count = _.get(currentNode.data, 'relatedEntityCount.domain.total', 0)
label = `${this.$t('entity.graph.resolveDomain')}(${count})`
}
break
}
case 'app': {
count = _.get(currentNode.data, 'relatedEntityCount.app.total', 0)
label = `${this.$t('entities.tab.relatedApp')}(${count})`
break
}
}
const primaryNode = this.generatePrimaryNode({
id: `${tempNode.data.type}-${tempNode.data.sourceName}`,
label: tempNode.label + `(${tempNode.data.count})`,
id: `${expandType}-${currentNode.id}`,
label: label,
data: {
sourceName: tempNode.data.sourceName,
sourceType: tempNode.data.sourceType,
type: tempNode.data.type,
isSubdomain: tempNode.data.isSubdomain || false,
count: tempNode.data.count
sourceName: currentNode.id,
sourceType: currentNode.data.type,
type: expandType,
isSubdomain: isSubdomain,
count: count
}
})
// 新node放入source node的childNodes中
@@ -1301,7 +1328,6 @@ export default {
this.graph.changeData(this.graphData)
}
}
}
},
async mounted () {
if (this.entity.entityType && this.entity.entityName) {