From af88c552154dcab2857ba51c0e0146704e050d43 Mon Sep 17 00:00:00 2001 From: "qumeng039@126.com" <86925389+qumen@users.noreply.github.com> Date: Fri, 1 Aug 2025 14:48:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E4=BA=AE=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/communityNode.vue | 1 + .../LinkPrediction/components/detailNode.vue | 50 +++++++++++++------ 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/views/LinkPrediction/components/communityNode.vue b/src/views/LinkPrediction/components/communityNode.vue index ec26d97..b6efcf3 100644 --- a/src/views/LinkPrediction/components/communityNode.vue +++ b/src/views/LinkPrediction/components/communityNode.vue @@ -35,6 +35,7 @@ const initChart = () => { nodesNum: item.nodesNum, neighbors: item.neighbors, category: item.isIncludePredictNodes ? 1 : 0, + selfIncludeImplicitRelationship: item.neighbors.map((nei) => nei.id).includes(item.id) && //若该社团的id在该社团邻居中可以找到,说明自己这个社团中有互动隐关系 item.neighbors.find((nei) => nei.id == item.id).isHidden diff --git a/src/views/LinkPrediction/components/detailNode.vue b/src/views/LinkPrediction/components/detailNode.vue index 08678b8..04f6091 100644 --- a/src/views/LinkPrediction/components/detailNode.vue +++ b/src/views/LinkPrediction/components/detailNode.vue @@ -65,7 +65,7 @@ import { nextTick, defineProps } from "vue" -import { TansTimestamp } from "@/utils/transform" +import { TansTimestamp, getAvatarUrl } from "@/utils/transform" import nodeHoverImg from "@/assets/images/nodeHover.png" import * as echarts from "echarts" import { storeToRefs } from "pinia" @@ -297,6 +297,8 @@ const initChart = async () => { nodes = props.interactionStore.communityDetailNodeList.map((item) => ({ id: item.userId, name: item.userName, + defaultAvatar: getAvatarUrl(item.defaultAvatar), + activeAvatar: getAvatarUrl(item.activeAvatar), symbolSize: 40, postNum: item.postNum, fancy: item.fans @@ -453,6 +455,8 @@ const initChart = async () => { animationDurationUpdate: 3500, // 节点移动更平滑 data: chartsData.value.nodes.map((node) => ({ ...node, + symbol: node.defaultAvatar ? `image://${node.defaultAvatar}` : "circle", + symbolSize: node.defaultAvatar ? 140 : 40, itemStyle: { color: new echarts.graphic.RadialGradient(0.98, 0.38, 0.9, [ { offset: 1, color: "#1a3860" }, // 最左侧 @@ -490,23 +494,37 @@ const initChart = async () => { const highLightUserNodes = (userIds) => { if (!userIds) return - chart.dispatchAction({ - type: "downplay", - seriesIndex: 0 - }) + // 只让高亮节点显示 activeAvatar,其他节点恢复默认头像或圆形 + chartsData.value.nodes.forEach((node) => { + if (userIds.includes(node.id) && node.activeAvatar) { + node.symbol = `image://${node.activeAvatar}` + node.symbolSize = 140 + } else { + node.symbol = "circle" + node.symbolSize = 40 + node.itemStyle = { + color: new echarts.graphic.RadialGradient(0.98, 0.38, 0.9, [ + { offset: 1, color: "#1a3860" }, // 最左侧 + { offset: 0.5, color: "#38546b" }, // 中间 + { offset: 0, color: "#5fb3b3" } // 最右侧 + ]), - setTimeout(() => { - //等待所有节点添加完毕后再查找 - userIds.forEach((id) => { - const index = chartsData.value.nodes.findIndex((node) => node.id === id) - if (index != -1) { - chart.dispatchAction({ - type: "highlight", - dataIndex: index - }) + opacity: 1, + borderColor: "#46C6AD", + borderWidth: 1, + shadowBlur: 4, + borderType: "dashed", + shadowColor: "rgba(19, 27, 114, 0.25)" } - }) - }, 1000) + } + }) + chart.setOption({ + series: [ + { + data: chartsData.value.nodes + } + ] + }) } onMounted(() => {