SocialNetworks_duan/src/views/LinkPrediction/socialGroups/components/graph.vue

65 lines
1.7 KiB
Vue
Raw Normal View History

2025-07-29 12:13:55 +08:00
<template>
<div class="graph-component">
<img :src="title" alt="" class="title" />
<CommunityNode
2025-07-29 16:25:28 +08:00
v-if="socialGroupsStore.curComponent == 'CommunityNode'"
2025-07-29 12:13:55 +08:00
@click:node="handleClickNode"
@click:edge="handleClickEdge"
></CommunityNode>
<DetailNode
v-else
@click:goback="handleClickGoBack"
></DetailNode>
</div>
</template>
<script setup>
2025-07-29 16:25:28 +08:00
import { defineProps } from "vue"
2025-07-29 12:13:55 +08:00
import CommunityNode from "./communityNode.vue"
import DetailNode from "./detailNode.vue"
import { useSocialGroupsStore } from "@/store/llinkPrediction/index"
const socialGroupsStore = useSocialGroupsStore()
const props = defineProps({
title: {
type: String,
default: ""
}
})
const handleClickNode = async (nodeInfo) => {
2025-07-29 16:25:28 +08:00
// 点击节点
socialGroupsStore.initGraphCommunityDetailNode([nodeInfo.id])
socialGroupsStore.curComponent = "detailNode"
2025-07-29 12:13:55 +08:00
}
const handleClickEdge = async (edgeInfo) => {
2025-07-29 16:25:28 +08:00
socialGroupsStore.curComponent = "detailNode"
2025-07-30 11:28:22 +08:00
// 先设置socialGroupsStore.clickEdgeTimeList
await socialGroupsStore.getClickEdgeTimeList([edgeInfo.source, edgeInfo.target])
// 点击边时需要将timeList设置成clickEdgeTimeList
socialGroupsStore.setTimeList(socialGroupsStore.clickEdgeTimeList)
const lastTime = socialGroupsStore.clickEdgeTimeList[socialGroupsStore.clickEdgeTimeList?.length - 1]
socialGroupsStore.initGraphCommunityDetailNode([edgeInfo.source, edgeInfo.target], lastTime)
2025-07-29 12:13:55 +08:00
}
const handleClickGoBack = (currentComponentName) => {
2025-07-29 16:25:28 +08:00
socialGroupsStore.curComponent = currentComponentName
2025-07-29 12:13:55 +08:00
}
</script>
<style scoped lang="less">
.graph-component {
width: 100%;
height: 100%;
position: relative;
.title {
margin: 0 auto;
}
.graph-container {
width: 100%;
height: 93%;
}
}
</style>