From 3bdde47c607e58e6e89fc6727744fe55b0f1b908 Mon Sep 17 00:00:00 2001 From: CN-JS-HuiBai Date: Mon, 6 Apr 2026 19:32:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 135e2bc..289d5ae 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -977,16 +977,22 @@ const isForward = (start === pts[0]); // Calculate curveness: ensure all lines are slightly curved + // Use a canonical hash of the route endpoints to deterministically decide the curve direction + // This helps spread lines across the map even for single routes + const names = [route.source, route.dest].sort(); + const routeHash = (names[0] + names[1]).split('').reduce((acc, char) => acc + char.charCodeAt(0), 0); + const baseSign = (routeHash % 2 === 0 ? 1 : -1); + let finalCurve = 0; if (count === 1) { - finalCurve = 0.15; // Default slight curve for single lines + // Single lines get a decent curve, alternating direction based on hash + finalCurve = 0.2 * baseSign; } else { - // Spread overlapping lines: 0.15, -0.15, 0.3, -0.3... - // This creates an "eye" or "fan" effect where no line is straight - const magnitude = 0.15 + Math.floor(i / 2) * 0.15; + // Multiple lines between same points fan out with increasing magnitude + const magnitude = 0.2 + Math.floor(i / 2) * 0.15; const spread = (i % 2 === 0) ? magnitude : -magnitude; - // Adjust sign based on direction so they occupy unique visual slots - finalCurve = isForward ? spread : -spread; + // Apply baseSign to ensure the whole group isn't biased to one side + finalCurve = isForward ? (spread * baseSign) : (-spread * baseSign); } finalSeries.push({