629 lines
18 KiB
JavaScript
629 lines
18 KiB
JavaScript
import { defineStore } from "pinia"
|
||
import {
|
||
getGroupUserListFromInteraction,
|
||
getGroupUserListFromTriangle,
|
||
getGroupUserListFromSocial,
|
||
getInteractionPostList,
|
||
getInteractionHiddenPostList,
|
||
getInteractionCommunityNodes,
|
||
getInteractionCommunityDetailNodes,
|
||
getInteractionCommunityStatistics,
|
||
getSocialCommunityList,
|
||
getSocialCommunityStatistics,
|
||
getSocialCommunityDetailNodes,
|
||
getSocialPostListByRelationId,
|
||
getInteractionCommunityDetailFromUserGroup
|
||
} from "@/service/api/linkPrediction"
|
||
|
||
import defaultAvatar from "@/assets/images/avatar/default.png"
|
||
import nodePrefix from "@/assets/images/linkPrediction/icon/node-count-prefix.png"
|
||
import communityPrefix from "@/assets/images/linkPrediction/icon/community-count-prefix.png"
|
||
import hiddenPrefix from "@/assets/images/linkPrediction/icon/hidden-count-prefix.png"
|
||
import tightCommunityPrefix from "@/assets/images/linkPrediction/icon/tightCommunityPrefix.png"
|
||
|
||
export const useCharacterInteractionStore = defineStore("characterInteraction", {
|
||
state: () => ({
|
||
userList: [], //用户组列表
|
||
userChartList: [], //组相关性
|
||
posts: [], //贴文列表
|
||
communityNodeList: [], //所有社团数据
|
||
curComponent: "CommunityNode",
|
||
curSelecedGroupIds: [],
|
||
communityDetailNodeRelation: [], //点击一级界面后,查询到的节点间关系
|
||
communityDetailNodeList: [], //节点用户列表
|
||
timeList: [],
|
||
predictionUserIds: [], //包含从用户组选择的用户id或者是点击某个社团或者连边后,所需要高亮的所有用户的id
|
||
anlysisList: [
|
||
{
|
||
id: 1,
|
||
title: "平均评论数",
|
||
unit: "数量",
|
||
xAxis: [0, 20, 40, 60, 80, 100],
|
||
max: 100,
|
||
rows: [
|
||
{ label: "目标用户", value: 98.8, type: "leader" },
|
||
{ label: "所有用户", value: 0.01, type: "user" }
|
||
]
|
||
},
|
||
{
|
||
id: 2,
|
||
title: "平均转发次数",
|
||
unit: "数量",
|
||
xAxis: [0, 3, 6, 9, 12, 16, 18],
|
||
max: 18,
|
||
rows: [
|
||
{ label: "目标用户", value: 17, type: "leader" },
|
||
{ label: "所有用户", value: 0.01, type: "user" }
|
||
]
|
||
},
|
||
{
|
||
id: 3,
|
||
title: "互动时间间隔",
|
||
unit: "秒",
|
||
xAxis: [0, 30, 60, 90, 120, 150],
|
||
max: 150,
|
||
rows: [
|
||
{ label: "目标用户", value: 3.63, type: "leader", highlight: false },
|
||
{ label: "所有用户", value: 127.63, type: "user" }
|
||
]
|
||
}
|
||
],
|
||
wordCloudData: [
|
||
{
|
||
text: "佩洛西",
|
||
top: 115.5,
|
||
left: 215.5,
|
||
width: 109,
|
||
height: 40,
|
||
fontSize: 28,
|
||
opacity: 1
|
||
},
|
||
{ text: "中国", top: 183.5, left: 69.5, width: 73, height: 35, fontSize: 22, opacity: 1 },
|
||
{
|
||
text: "中国人民解放军",
|
||
top: 72.5,
|
||
left: 132.5,
|
||
width: 123,
|
||
height: 22,
|
||
fontSize: 12,
|
||
opacity: 1
|
||
},
|
||
{
|
||
text: "中美关系",
|
||
top: 171.5,
|
||
left: 212.5,
|
||
width: 81,
|
||
height: 22,
|
||
fontSize: 14,
|
||
opacity: 0.8
|
||
},
|
||
{ text: "台独", top: 135.5, left: 42.5, width: 57, height: 24, fontSize: 16, opacity: 1 },
|
||
{
|
||
text: "台海和平",
|
||
top: 228.5,
|
||
left: 230.5,
|
||
width: 81,
|
||
height: 22,
|
||
fontSize: 14,
|
||
opacity: 0.8
|
||
},
|
||
{
|
||
text: "坚决反对",
|
||
top: 200.5,
|
||
left: 38.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 0.7
|
||
},
|
||
{
|
||
text: "联合公报",
|
||
top: 241.5,
|
||
left: 130.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 0.7
|
||
},
|
||
{
|
||
text: "有力反制",
|
||
top: 211.5,
|
||
left: 143.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 1
|
||
},
|
||
{ text: "白宫", top: 176.5, left: 15.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 },
|
||
{ text: "内政", top: 87.5, left: 36.5, width: 53, height: 22, fontSize: 14, opacity: 1 },
|
||
{ text: "访台", top: 103.5, left: 95.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 },
|
||
{ text: "领土", top: 57.5, left: 72.5, width: 49, height: 19, fontSize: 12, opacity: 0.6 },
|
||
{ text: "原则", top: 77.5, left: 264.5, width: 49, height: 19, fontSize: 12, opacity: 0.7 },
|
||
{ text: "台湾", top: 195.5, left: 287.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 }
|
||
],
|
||
|
||
statisticsList: [
|
||
{ id: 1, icon: nodePrefix, name: "节点数", key: "nodesCount" },
|
||
{ id: 2, icon: communityPrefix, name: "社团数", key: "groupCount" },
|
||
{ id: 3, icon: hiddenPrefix, name: "隐关系数", key: "hiddenInteractionCount" }
|
||
],
|
||
statisticsDetailList: [
|
||
{ id: 1, icon: nodePrefix, name: "节点数", key: "nodesCount" },
|
||
{ id: 2, icon: communityPrefix, name: "社团数", key: "groupCount" },
|
||
{ id: 3, icon: hiddenPrefix, name: "隐关系数", key: "hiddenInteractionCount" }
|
||
]
|
||
}),
|
||
actions: {
|
||
async initGroupList() {
|
||
const res = await getGroupUserListFromInteraction()
|
||
if (res.code != 200) {
|
||
return
|
||
}
|
||
this.userList = res.data.userList
|
||
},
|
||
|
||
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, relationId = -1, time = "2024-05-16 16:56:04") {
|
||
this.curSelecedGroupIds = ids
|
||
const res = await getInteractionCommunityDetailNodes(ids, relationId, time)
|
||
if (res.code != 200) return
|
||
this.statisticsDetailList = this.statisticsDetailList.map((item) => ({
|
||
...item,
|
||
count: res.data.communityStatistics[item.key]
|
||
}))
|
||
this.communityDetailNodeRelation = res.data.userRelation
|
||
this.communityDetailNodeList = res.data.userList
|
||
this.timeList = res.data.timeList
|
||
this.predictionUserIds = res.data.predictNodes
|
||
},
|
||
async initGraphStatistics() {
|
||
const res = await getInteractionCommunityStatistics()
|
||
this.statisticsList = this.statisticsList.map((item) => ({
|
||
...item,
|
||
count: res.data[item.key]
|
||
}))
|
||
}
|
||
},
|
||
persist: true // 开启持久化
|
||
})
|
||
|
||
export const useSocialGroupsStore = defineStore("socialGroups", {
|
||
state: () => ({
|
||
userList: [],
|
||
communityNodeList: [],
|
||
curComponent: "CommunityNode",
|
||
curSelecedGroupIds: [],
|
||
communityDetailNodeList: [],
|
||
timeList: [],
|
||
statisticsList: [
|
||
{ id: 1, icon: nodePrefix, name: "节点数", key: "nodesCount" },
|
||
{ id: 2, icon: communityPrefix, name: "社团数", key: "groupCount" },
|
||
{ id: 3, icon: tightCommunityPrefix, name: "紧密团体数", key: "hiddenInteractionCount" }
|
||
],
|
||
statisticsDetailList: [
|
||
{ id: 1, icon: nodePrefix, name: "节点数", key: "nodesCount" },
|
||
{ id: 2, icon: communityPrefix, name: "社团数", key: "groupCount" },
|
||
{ id: 3, icon: tightCommunityPrefix, name: "紧密团体数", key: "hiddenInteractionCount" }
|
||
],
|
||
userChartList: [
|
||
{
|
||
id: 1,
|
||
group: [
|
||
{ id: 1, name: "Polo Hun", avatar: defaultAvatar, fancy: 634, post: 32 },
|
||
{ id: 2, name: "楊政子", avatar: defaultAvatar, fancy: 5556, post: 23 },
|
||
{ id: 3, name: "楊政子", avatar: defaultAvatar, fancy: 5556, post: 23 }
|
||
],
|
||
number: "0.60"
|
||
},
|
||
{
|
||
id: 2,
|
||
group: [
|
||
{
|
||
id: 7,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 0,
|
||
post: 0
|
||
},
|
||
{
|
||
id: 8,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 564,
|
||
post: 13
|
||
},
|
||
{
|
||
id: 9,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 564,
|
||
post: 13
|
||
}
|
||
],
|
||
number: 0.45
|
||
},
|
||
{
|
||
id: 3,
|
||
group: [
|
||
{
|
||
id: 10,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 0,
|
||
post: 0
|
||
},
|
||
{
|
||
id: 11,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 564,
|
||
post: 13
|
||
},
|
||
{
|
||
id: 12,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 564,
|
||
post: 13
|
||
}
|
||
],
|
||
number: 0.32
|
||
}
|
||
],
|
||
posts: [],
|
||
anlysisList: [
|
||
{
|
||
id: 1,
|
||
title: "平均评论数",
|
||
unit: "数量",
|
||
xAxis: [0, 20, 40, 60, 80, 100],
|
||
max: 100,
|
||
rows: [
|
||
{ label: "目标用户", value: 37.33, type: "leader" },
|
||
{ label: "所有用户", value: 0.06, type: "user" }
|
||
]
|
||
},
|
||
{
|
||
id: 2,
|
||
title: "平均转发次数",
|
||
unit: "数量",
|
||
xAxis: [0, 0.1, 0.2, 0.3, 0.4, 0.5],
|
||
max: 0.5,
|
||
rows: [
|
||
{ label: "目标用户", value: 0.31, type: "leader" },
|
||
{ label: "所有用户", value: 0.004, type: "user" }
|
||
]
|
||
},
|
||
{
|
||
id: 3,
|
||
title: "互动时间间隔",
|
||
unit: "秒",
|
||
xAxis: [0, 100, 200, 300, 400, 500],
|
||
max: 600,
|
||
rows: [
|
||
{ label: "目标用户", value: 42.55, type: "leader", highlight: false },
|
||
{ label: "所有用户", value: 582.23, type: "user" }
|
||
]
|
||
}
|
||
],
|
||
wordCloudData: [
|
||
{
|
||
text: "佩洛西",
|
||
top: 115.5,
|
||
left: 215.5,
|
||
width: 109,
|
||
height: 40,
|
||
fontSize: 28,
|
||
opacity: 1
|
||
},
|
||
{ text: "中国", top: 183.5, left: 69.5, width: 73, height: 35, fontSize: 22, opacity: 1 },
|
||
{
|
||
text: "中国人民解放军",
|
||
top: 72.5,
|
||
left: 132.5,
|
||
width: 123,
|
||
height: 22,
|
||
fontSize: 12,
|
||
opacity: 1
|
||
},
|
||
{
|
||
text: "中美关系",
|
||
top: 171.5,
|
||
left: 212.5,
|
||
width: 81,
|
||
height: 22,
|
||
fontSize: 14,
|
||
opacity: 0.8
|
||
},
|
||
{ text: "台独", top: 135.5, left: 42.5, width: 57, height: 24, fontSize: 16, opacity: 1 },
|
||
{
|
||
text: "台海和平",
|
||
top: 228.5,
|
||
left: 230.5,
|
||
width: 81,
|
||
height: 22,
|
||
fontSize: 14,
|
||
opacity: 0.8
|
||
},
|
||
{
|
||
text: "坚决反对",
|
||
top: 200.5,
|
||
left: 38.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 0.7
|
||
},
|
||
{
|
||
text: "联合公报",
|
||
top: 241.5,
|
||
left: 130.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 0.7
|
||
},
|
||
{
|
||
text: "有力反制",
|
||
top: 211.5,
|
||
left: 143.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 1
|
||
},
|
||
{ text: "白宫", top: 176.5, left: 15.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 },
|
||
{ text: "内政", top: 87.5, left: 36.5, width: 53, height: 22, fontSize: 14, opacity: 1 },
|
||
{ text: "访台", top: 103.5, left: 95.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 },
|
||
{ text: "领土", top: 57.5, left: 72.5, width: 49, height: 19, fontSize: 12, opacity: 0.6 },
|
||
{ text: "原则", top: 77.5, left: 264.5, width: 49, height: 19, fontSize: 12, opacity: 0.7 },
|
||
{ text: "台湾", top: 195.5, left: 287.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 }
|
||
]
|
||
}),
|
||
actions: {
|
||
// 互动行为相似列表数据
|
||
async initGroupList() {
|
||
const res = await getGroupUserListFromTriangle()
|
||
if (res.code != 200) return
|
||
// 按rank属性升序排序userList
|
||
res.data.userList.sort((a, b) => a.rank - b.rank)
|
||
this.userList = res.data.userList
|
||
},
|
||
// 事件脉络分析中的帖文数据
|
||
async initPostList(relationId) {
|
||
const res = await getSocialPostListByRelationId(relationId)
|
||
if (res.code != 200) return
|
||
if (this.posts.length != 0) {
|
||
this.posts.push(...res.data)
|
||
} else {
|
||
this.posts = res.data
|
||
}
|
||
},
|
||
// 获取对应用户组的postList
|
||
async getSocialGroupPostListByRelationId(relationId) {
|
||
const res = await getSocialPostListByRelationId(relationId)
|
||
if (res.code != 200) return
|
||
// console.log("打印对应relationId的帖文列表:", res.data)
|
||
this.posts = res.data
|
||
},
|
||
async initGraphCommunityNode() {
|
||
const res = await getSocialCommunityList()
|
||
if (res.code != 200) return
|
||
this.communityNodeList = res.data
|
||
},
|
||
// 社交紧密团体识别的社团统计
|
||
async initGraphStatistics() {
|
||
const res = await getSocialCommunityStatistics()
|
||
this.statisticsList = this.statisticsList.map((item) => ({
|
||
...item,
|
||
count: res.data[item.key]
|
||
}))
|
||
},
|
||
// 传递社交团体的数组,获取其详情
|
||
async initGraphCommunityDetailNode(ids, time = "2024-05-16 16:56:04") {
|
||
this.curSelecedGroupIds = ids
|
||
const res = await getSocialCommunityDetailNodes(ids, time)
|
||
if (res.code != 200) return
|
||
this.statisticsDetailList = this.statisticsDetailList.map((item) => ({
|
||
...item,
|
||
count: res.data.communityStatistics[item.key]
|
||
}))
|
||
this.timeList = res.data.timeList || []
|
||
this.communityDetailNodeList = res.data.userRelation
|
||
}
|
||
},
|
||
persist: true // 开启持久化
|
||
})
|
||
|
||
export const useCharacterHiddenStore = defineStore("characterHidden", {
|
||
state: () => ({
|
||
userList: [],
|
||
userChartList: [
|
||
{
|
||
id: 1,
|
||
group: [
|
||
{ id: 1, name: "Polo Hun", avatar: defaultAvatar, fancy: 634, post: 32 },
|
||
{ id: 2, name: "楊政子", avatar: defaultAvatar, fancy: 5556, post: 23 }
|
||
],
|
||
number: "0.36"
|
||
},
|
||
{
|
||
id: 2,
|
||
group: [
|
||
{
|
||
id: 7,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 0,
|
||
post: 0
|
||
},
|
||
{
|
||
id: 8,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 564,
|
||
post: 13
|
||
}
|
||
],
|
||
number: 0.28
|
||
},
|
||
{
|
||
id: 3,
|
||
group: [
|
||
{
|
||
id: 9,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 0,
|
||
post: 0
|
||
},
|
||
{
|
||
id: 10,
|
||
name: "一人一讚 馬總統感恩有您 永遠支...",
|
||
avatar: defaultAvatar,
|
||
fancy: 564,
|
||
post: 13
|
||
}
|
||
],
|
||
number: 0.24
|
||
}
|
||
],
|
||
posts: [],
|
||
|
||
anlysisList: [
|
||
{
|
||
id: 1,
|
||
title: "平均评论数",
|
||
unit: "数量",
|
||
xAxis: [0, 20, 40, 60, 80, 100],
|
||
max: 100,
|
||
rows: [
|
||
{ label: "目标用户", value: 90.8, type: "leader" },
|
||
{ label: "所有用户", value: 0.01, type: "user" }
|
||
]
|
||
},
|
||
{
|
||
id: 2,
|
||
title: "平均转发次数",
|
||
unit: "数量",
|
||
xAxis: [0, 3, 6, 9, 12, 16, 18],
|
||
max: 18,
|
||
rows: [
|
||
{ label: "目标用户", value: 17, type: "leader" },
|
||
{ label: "所有用户", value: 0.01, type: "user" }
|
||
]
|
||
},
|
||
{
|
||
id: 3,
|
||
title: "互动时间间隔",
|
||
unit: "秒",
|
||
xAxis: [0, 30, 60, 90, 120, 150],
|
||
max: 150,
|
||
rows: [
|
||
{ label: "目标用户", value: 3.63, type: "leader", highlight: false },
|
||
{ label: "所有用户", value: 127.63, type: "user" }
|
||
]
|
||
}
|
||
],
|
||
wordCloudData: [
|
||
{
|
||
text: "佩洛西",
|
||
top: 115.5,
|
||
left: 215.5,
|
||
width: 109,
|
||
height: 40,
|
||
fontSize: 28,
|
||
opacity: 1
|
||
},
|
||
{ text: "中国", top: 183.5, left: 69.5, width: 73, height: 35, fontSize: 22, opacity: 1 },
|
||
{
|
||
text: "中国人民解放军",
|
||
top: 72.5,
|
||
left: 132.5,
|
||
width: 123,
|
||
height: 22,
|
||
fontSize: 12,
|
||
opacity: 1
|
||
},
|
||
{
|
||
text: "中美关系",
|
||
top: 171.5,
|
||
left: 212.5,
|
||
width: 81,
|
||
height: 22,
|
||
fontSize: 14,
|
||
opacity: 0.8
|
||
},
|
||
{ text: "台独", top: 135.5, left: 42.5, width: 57, height: 24, fontSize: 16, opacity: 1 },
|
||
{
|
||
text: "台海和平",
|
||
top: 228.5,
|
||
left: 230.5,
|
||
width: 81,
|
||
height: 22,
|
||
fontSize: 14,
|
||
opacity: 0.8
|
||
},
|
||
{
|
||
text: "坚决反对",
|
||
top: 200.5,
|
||
left: 38.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 0.7
|
||
},
|
||
{
|
||
text: "联合公报",
|
||
top: 241.5,
|
||
left: 130.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 0.7
|
||
},
|
||
{
|
||
text: "有力反制",
|
||
top: 211.5,
|
||
left: 143.5,
|
||
width: 73,
|
||
height: 19,
|
||
fontSize: 12,
|
||
opacity: 1
|
||
},
|
||
{ text: "白宫", top: 176.5, left: 15.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 },
|
||
{ text: "内政", top: 87.5, left: 36.5, width: 53, height: 22, fontSize: 14, opacity: 1 },
|
||
{ text: "访台", top: 103.5, left: 95.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 },
|
||
{ text: "领土", top: 57.5, left: 72.5, width: 49, height: 19, fontSize: 12, opacity: 0.6 },
|
||
{ text: "原则", top: 77.5, left: 264.5, width: 49, height: 19, fontSize: 12, opacity: 0.7 },
|
||
{ text: "台湾", top: 195.5, left: 287.5, width: 49, height: 19, fontSize: 12, opacity: 0.8 }
|
||
]
|
||
}),
|
||
actions: {
|
||
async initGroupList() {
|
||
const res = await getGroupUserListFromSocial()
|
||
if (res.code != 200) return
|
||
this.userList = res.data.userList
|
||
},
|
||
async initPostList(autoIncrement) {
|
||
const res = await getInteractionHiddenPostList(autoIncrement)
|
||
if (res.code != 200) return
|
||
if (this.posts.length != 0) this.posts.push(...res.data)
|
||
else this.posts = res.data
|
||
}
|
||
},
|
||
persist: true // 开启持久化
|
||
})
|