SHA256
Исправили отображение связей V3
This commit is contained in:
@@ -55,7 +55,8 @@ export function createExplorerGraph() {
|
||||
// Если граф обновился, старые исходящие рёбра этого владельца больше не действуют.
|
||||
for (const edgeKey of edges.keys()) if (edgeKey.startsWith(`${owner}\u0000`)) edges.delete(edgeKey);
|
||||
const close = new Set((graph?.outCloseFriends || []).map(keyOf));
|
||||
const inbound = new Set([...(graph?.inFriends || []), ...(graph?.inCloseFriends || [])].map(keyOf));
|
||||
const inboundClose = new Set((graph?.inCloseFriends || []).map(keyOf));
|
||||
const inbound = new Set([...(graph?.inFriends || []), ...inboundClose].map(keyOf));
|
||||
// Сохраняем оригинальный регистр логина для серверного API (ключи графа
|
||||
// нормализуем независимо, только для сопоставления вершин).
|
||||
const friendNames = new Map();
|
||||
@@ -68,6 +69,7 @@ export function createExplorerGraph() {
|
||||
remember({ login: friendNames.get(id) }, id);
|
||||
edges.set(`${owner}\u0000${id}`, {
|
||||
from: owner, to: id, type: close.has(id) ? 'close_friend' : 'friend',
|
||||
reverseType: inboundClose.has(id) ? 'close_friend' : (inbound.has(id) ? 'friend' : null),
|
||||
mutual: inbound.has(id),
|
||||
});
|
||||
}
|
||||
@@ -162,7 +164,8 @@ export function createExplorerGraph() {
|
||||
if (!isExpanded(edge.from) && !isExpanded(edge.to)) continue;
|
||||
const detail = {
|
||||
id: parent,
|
||||
relationType: edge.type === 'close_friend' || reverse?.type === 'close_friend' ? 'close_friend' : 'friend',
|
||||
relationType: edge.type,
|
||||
reverseRelationType: reverse?.type || edge.reverseType || null,
|
||||
mutual: Boolean(edge.mutual || reverse),
|
||||
strength: edge.type === 'close_friend' ? 0.9 : 0.55,
|
||||
};
|
||||
|
||||
@@ -89,7 +89,7 @@ const DOUBLE_TAP_MS = 320; // окно двойного тапа по фо
|
||||
const RELATION_COLORS = {
|
||||
family: 'rgba(255, 159, 94, 0.92)',
|
||||
friend: 'rgba(120, 179, 255, 0.9)',
|
||||
close_friend: 'rgba(120, 179, 255, 0.98)',
|
||||
close_friend: 'rgba(255, 76, 92, 0.98)',
|
||||
business: 'rgba(190, 150, 255, 0.9)',
|
||||
contact: 'rgba(170, 190, 220, 0.7)',
|
||||
};
|
||||
@@ -110,7 +110,7 @@ function easeOutCubic(t) {
|
||||
const RELATION_COLORS_LIGHT = {
|
||||
family: 'rgba(184, 92, 20, 0.9)',
|
||||
friend: 'rgba(38, 96, 196, 0.9)',
|
||||
close_friend: 'rgba(38, 96, 196, 0.98)',
|
||||
close_friend: 'rgba(214, 38, 55, 0.98)',
|
||||
business: 'rgba(108, 62, 200, 0.9)',
|
||||
contact: 'rgba(92, 98, 121, 0.75)',
|
||||
};
|
||||
@@ -971,6 +971,8 @@ export function createForceGraph({ stage, model, onCenterTap, onNodeTap, onNodeL
|
||||
function renderHistoryEdges() {
|
||||
const Z = zoom;
|
||||
const parts = [];
|
||||
const defs = [];
|
||||
let gradientIndex = 0;
|
||||
const tx = (n) => centerX + camX + n.x * Z;
|
||||
const ty = (n) => centerY + camY + n.y * Z;
|
||||
|
||||
@@ -1014,6 +1016,7 @@ export function createForceGraph({ stage, model, onCenterTap, onNodeTap, onNodeL
|
||||
const cpx = 2 * desX - mx;
|
||||
const cpy = 2 * desY - my;
|
||||
const relationType = String(ref?.relationType || n.relationType || 'contact');
|
||||
const reverseRelationType = String(ref?.reverseRelationType || '');
|
||||
const strength = Math.max(0, Math.min(1, Number(ref?.strength) || Number(n.strength) || 0.5));
|
||||
const opacity = Math.min(childOpacity, parentOpacity);
|
||||
const shine = Boolean(parent.shining && n.shining) && !n.hidden;
|
||||
@@ -1022,6 +1025,12 @@ export function createForceGraph({ stage, model, onCenterTap, onNodeTap, onNodeL
|
||||
parts.push(...directedFriendEdgePaths(x1, y1, cpx, cpy, x2, y2, relationColor(relationType), opacity * 0.82));
|
||||
continue;
|
||||
}
|
||||
let edgeStroke = relationColor(relationType);
|
||||
if (reverseRelationType && reverseRelationType !== relationType) {
|
||||
const gradientId = `fg-relation-gradient-${gradientIndex++}`;
|
||||
defs.push(`<linearGradient id="${gradientId}" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="${relationColor(relationType)}"/><stop offset="100%" stop-color="${relationColor(reverseRelationType)}"/></linearGradient>`);
|
||||
edgeStroke = `url(#${gradientId})`;
|
||||
}
|
||||
if (shine) {
|
||||
const pnx = -uy;
|
||||
const pny = ux;
|
||||
@@ -1038,14 +1047,14 @@ export function createForceGraph({ stage, model, onCenterTap, onNodeTap, onNodeL
|
||||
parts.push(`<path class="fg-plasma-core" d="${d}" opacity="${opacity.toFixed(3)}" />`);
|
||||
} else {
|
||||
const d = `M${x1.toFixed(1)} ${y1.toFixed(1)} Q${cpx.toFixed(1)} ${cpy.toFixed(1)} ${x2.toFixed(1)} ${y2.toFixed(1)}`;
|
||||
const col = relationColor(relationType);
|
||||
const col = edgeStroke;
|
||||
const haloWidth = (2.6 + strength * 1.4).toFixed(2);
|
||||
parts.push(`<path d="${d}" fill="none" stroke="${col}" stroke-width="${haloWidth}" stroke-linecap="round" opacity="${(0.22 * opacity).toFixed(2)}" />`);
|
||||
parts.push(`<path d="${d}" fill="none" stroke="${col}" stroke-width="1.2" stroke-linecap="round" opacity="${(0.70 * opacity).toFixed(2)}" />`);
|
||||
}
|
||||
}
|
||||
}
|
||||
edgesSvg.innerHTML = parts.join('');
|
||||
edgesSvg.innerHTML = `<defs>${defs.join('')}</defs>${parts.join('')}`;
|
||||
}
|
||||
|
||||
function renderEdges() {
|
||||
|
||||
Reference in New Issue
Block a user