|
|
@@ -373,8 +373,8 @@ const props = defineProps({
|
|
|
|
|
|
const emit = defineEmits(['update:matchListCollapsed'])
|
|
|
|
|
|
-// 不需要显示的节点字段
|
|
|
-const hiddenNodeFields = ['index', 'x', 'y', 'vx', 'vy', 'fx', 'fy']
|
|
|
+// 不需要显示的节点字段(D3相关字段和children)
|
|
|
+const hiddenNodeFields = ['index', 'x', 'y', 'vx', 'vy', 'fx', 'fy', 'children', 'id', 'data', 'parent', 'depth', 'height']
|
|
|
|
|
|
const store = useGraphStore()
|
|
|
|
|
|
@@ -562,32 +562,62 @@ function getNodeColor(node) {
|
|
|
return '#888'
|
|
|
}
|
|
|
|
|
|
-// 节点的入边列表(按分数降序)
|
|
|
+// 节点的入边列表(按分数降序,同时查找帖子图谱和人设图谱)
|
|
|
const nodeInEdges = computed(() => {
|
|
|
if (!displayNode.value) return []
|
|
|
const nodeId = displayNode.value.id || displayNode.value.data?.id
|
|
|
if (!nodeId) return []
|
|
|
|
|
|
+ const edges = []
|
|
|
+
|
|
|
+ // 从帖子图谱查找
|
|
|
const postGraph = store.currentPostGraph
|
|
|
- if (!postGraph?.edges) return []
|
|
|
+ if (postGraph?.edges) {
|
|
|
+ for (const e of Object.values(postGraph.edges)) {
|
|
|
+ if (e.target === nodeId) edges.push(e)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- return Object.values(postGraph.edges)
|
|
|
- .filter(e => e.target === nodeId)
|
|
|
- .sort((a, b) => (b.score || 0) - (a.score || 0))
|
|
|
+ // 从人设图谱查找(如果是人设节点)
|
|
|
+ if (nodeId.startsWith('人设:')) {
|
|
|
+ const personaEdges = store.graphData?.edges
|
|
|
+ if (personaEdges) {
|
|
|
+ for (const e of Object.values(personaEdges)) {
|
|
|
+ if (e.target === nodeId) edges.push(e)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return edges.sort((a, b) => (b.score || 0) - (a.score || 0))
|
|
|
})
|
|
|
|
|
|
-// 节点的出边列表(按分数降序)
|
|
|
+// 节点的出边列表(按分数降序,同时查找帖子图谱和人设图谱)
|
|
|
const nodeOutEdges = computed(() => {
|
|
|
if (!displayNode.value) return []
|
|
|
const nodeId = displayNode.value.id || displayNode.value.data?.id
|
|
|
if (!nodeId) return []
|
|
|
|
|
|
+ const edges = []
|
|
|
+
|
|
|
+ // 从帖子图谱查找
|
|
|
const postGraph = store.currentPostGraph
|
|
|
- if (!postGraph?.edges) return []
|
|
|
+ if (postGraph?.edges) {
|
|
|
+ for (const e of Object.values(postGraph.edges)) {
|
|
|
+ if (e.source === nodeId) edges.push(e)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从人设图谱查找(如果是人设节点)
|
|
|
+ if (nodeId.startsWith('人设:')) {
|
|
|
+ const personaEdges = store.graphData?.edges
|
|
|
+ if (personaEdges) {
|
|
|
+ for (const e of Object.values(personaEdges)) {
|
|
|
+ if (e.source === nodeId) edges.push(e)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- return Object.values(postGraph.edges)
|
|
|
- .filter(e => e.source === nodeId)
|
|
|
- .sort((a, b) => (b.score || 0) - (a.score || 0))
|
|
|
+ return edges.sort((a, b) => (b.score || 0) - (a.score || 0))
|
|
|
})
|
|
|
|
|
|
// 获取节点名称(根据节点ID)
|
|
|
@@ -819,23 +849,33 @@ function renderMatchLayer(contentG, root, baseTreeHeight) {
|
|
|
|
|
|
if (matchEdges.length === 0) return
|
|
|
|
|
|
- // 收集匹配的人设节点(去重)
|
|
|
+ // 收集匹配的人设节点(去重),获取完整节点数据
|
|
|
const matchedPersonaMap = new Map()
|
|
|
for (const edge of matchEdges) {
|
|
|
if (!matchedPersonaMap.has(edge.target)) {
|
|
|
- // 从人设节点ID提取信息: "人设:目的点:标签:进行产品种草"
|
|
|
- const parts = edge.target.split(':')
|
|
|
- const name = parts[parts.length - 1]
|
|
|
- const dimension = parts[1] // 灵感点/目的点/关键点
|
|
|
- const type = parts[2] // 标签/分类/点
|
|
|
- matchedPersonaMap.set(edge.target, {
|
|
|
- id: edge.target,
|
|
|
- name: name,
|
|
|
- dimension: dimension,
|
|
|
- type: type,
|
|
|
- domain: '人设', // 人设节点:实心
|
|
|
- sourceEdges: [] // 连接的帖子节点
|
|
|
- })
|
|
|
+ // 从 store 获取完整的人设节点数据
|
|
|
+ const fullNode = store.getNode(edge.target)
|
|
|
+ if (fullNode) {
|
|
|
+ matchedPersonaMap.set(edge.target, {
|
|
|
+ ...fullNode,
|
|
|
+ id: edge.target,
|
|
|
+ sourceEdges: [] // 连接的帖子节点
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 回退:从节点ID提取基本信息
|
|
|
+ const parts = edge.target.split(':')
|
|
|
+ const name = parts[parts.length - 1]
|
|
|
+ const dimension = parts[1]
|
|
|
+ const type = parts[2]
|
|
|
+ matchedPersonaMap.set(edge.target, {
|
|
|
+ id: edge.target,
|
|
|
+ name: name,
|
|
|
+ dimension: dimension,
|
|
|
+ type: type,
|
|
|
+ domain: '人设',
|
|
|
+ sourceEdges: []
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
matchedPersonaMap.get(edge.target).sourceEdges.push({
|
|
|
sourceId: edge.source,
|