diff --git a/src/store/llinkPrediction/index.js b/src/store/llinkPrediction/index.js index c575f80..ae439be 100644 --- a/src/store/llinkPrediction/index.js +++ b/src/store/llinkPrediction/index.js @@ -25,7 +25,6 @@ import tightCommunityPrefix from "@/assets/images/linkPrediction/icon/tightCommu export const useCharacterInteractionStore = defineStore("characterInteraction", { state: () => ({ userList: [], //用户组列表 - userChartList: [], //组相关性 posts: [], //贴文列表 communityNodeList: [], //所有社团数据 curComponent: "CommunityNode", @@ -159,6 +158,7 @@ export const useCharacterInteractionStore = defineStore("characterInteraction", ] }), actions: { + //初始化用户组列表 async initGroupList() { const res = await getGroupUserListFromInteraction() if (res.code != 200) { @@ -166,20 +166,19 @@ export const useCharacterInteractionStore = defineStore("characterInteraction", } this.userList = res.data.userList.sort((a, b) => a.rank - b.rank) }, - - initGroupCorrelationForChart() { - this.userChartList = this.userList - }, + //初始化贴文数据 && 点击用户组列表展示该用户组的贴文 async initInteractionPostList(userGroupId) { const res = await getInteractionPostList(userGroupId) if (res.code != 200) return this.posts = res.data }, + //初始化社团节点 async initGraphCommunityNode() { const res = await getInteractionCommunityNodes() if (res.code != 200) return this.communityNodeList = res.data }, + //点击社团节点的黄色边,或者存在预测节点的社团,获取社团内部详情 async initGraphCommunityDetailNode(ids, time = "2024-05-16 16:56:04", relationId = -1) { this.curSelecedGroupIds = ids const res = await getInteractionCommunityDetailNodes(ids, relationId, time) @@ -203,6 +202,7 @@ export const useCharacterInteractionStore = defineStore("characterInteraction", this.timeList = res.data.timeList this.predictionUserIds = res.data.predictNodes }, + //初始化社团统计数据 async initGraphStatistics() { const res = await getInteractionCommunityStatistics() this.statisticsList = this.statisticsList.map((item) => ({ @@ -461,7 +461,7 @@ export const useSocialGroupsStore = defineStore("socialGroups", { this.curSelecedGroupIds = ids const res = await getSocialCommunityDetailNodes(ids, relationId, time) if (res.code != 200) return - console.log("index.js:",res.data) + console.log("index.js:", res.data) const customStatisticsObj = Object.assign({}, res.data.communityStatistics) //计算两个用户是否同属与同一个社团 if ( diff --git a/src/views/LinkPrediction/components/detailNode.vue b/src/views/LinkPrediction/components/detailNode.vue index 755d6cf..08678b8 100644 --- a/src/views/LinkPrediction/components/detailNode.vue +++ b/src/views/LinkPrediction/components/detailNode.vue @@ -76,9 +76,10 @@ const props = defineProps({ required: true } }) -const { communityDetailNodeRelation, timeList, predictionUserIds } = storeToRefs( - props.interactionStore -) + +const { communityDetailNodeRelation, timeList, predictionUserIds, curSelecedGroupIds } = + storeToRefs(props.interactionStore) + const emit = defineEmits(["click:goback"]) const chartsData = ref({}) const handleGoback = () => { @@ -86,6 +87,29 @@ const handleGoback = () => { emit("click:goback", "CommunityNode") } +// 时间轴相关数据 +const startTime = ref(new Date("2024-05-16 16:56:04")) +const endTime = ref(new Date("2024-05-23 10:16:56")) +const currentTime = ref(new Date("2024-05-16 16:56:04")) // 当前选中的时间 +const currentPosition = ref(0) // 初始位置 +const isPlaying = ref(false) // 是否自动播放 +let playTimer = null + +// 添加对curSelecedGroupIds的watch,确保切换列表项时重置时间轴 +watch( + curSelecedGroupIds, + (newIds) => { + if (newIds && newIds.length > 0) { + // 重置时间轴位置到起点 + currentPosition.value = 0 + currentTime.value = new Date("2024-05-16 16:56:04") + // 重新开始自动播放 + pause() // 先停止可能正在运行的计时器 + play() // 重新开始播放 + } + }, + { deep: true } +) //当点击时间轴的时候,communityDetailNodeList改变,重新更新关系图 watch( communityDetailNodeRelation, @@ -108,14 +132,6 @@ watch( { deep: true, immediate: true } ) -// 时间轴相关数据 -const startTime = ref(new Date("2024-05-16 16:56:04")) -const endTime = ref(new Date("2024-05-23 10:16:56")) -const currentTime = ref(new Date("2024-05-16 16:56:04")) // 当前选中的时间 -const currentPosition = ref(0) // 初始位置 -const isPlaying = ref(false) // 是否自动播放 -let playTimer = null - // 自动播放控制 const play = () => { if (isPlaying.value) return