1.3.8:帮助中心改垂直导航(修复关于页控制器长度);连线端点捕捉按画线侧取点不再乱飘

This commit is contained in:
2026-10-11 13:03:16 +08:00
parent 3210ac50d8
commit 0ecaac0930
11 changed files with 188 additions and 65 deletions
+38
View File
@@ -801,6 +801,44 @@ void main() {
.reduce((double x, double y) => x < y ? x : y);
expect(dmin, lessThan(2), reason: '路径应经过拖拽的角点');
});
test('端点捕捉稳定:按保存的画线侧取边框点(不随中心方向乱跳)', () {
const ArchShape a = ArchShape(
id: 'A',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(0, 0, 100, 100),
);
const ArchShape b = ArchShape(
id: 'B',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(300, 140, 100, 100),
);
final ArchDoc doc =
ArchDoc.empty.copyWith(shapes: <ArchShape>[a, b]);
final ArchConnector c1 = ArchConnector(
id: 'C1',
fromId: 'A',
from: const Offset(0, 50),
toId: 'B',
to: const Offset(350, 190),
);
// 从 A 的左侧画线:置左边中点 → 起点应留在左侧(目标在右下也不跳)。
final ArchConnGeometry g1 = archConnectorGeometry(doc, c1);
expect(g1.pts.first.dx, closeTo(0, 1));
// 从 A 的右侧画线:置右边中点 → 起点应留在右侧。
final ArchConnGeometry g2 =
archConnectorGeometry(doc, c1.copyWith(from: const Offset(100, 50)));
expect(g2.pts.first.dx, closeTo(100, 1));
// 保存端点为图形中心(程序化创建):退回朝向对方,且落在边框上。
final ArchConnGeometry g3 =
archConnectorGeometry(doc, c1.copyWith(from: a.rect.center));
final Offset p = g3.pts.first;
final bool onBorder = (p.dx - a.rect.left).abs() < 1 ||
(p.dx - a.rect.right).abs() < 1 ||
(p.dy - a.rect.top).abs() < 1 ||
(p.dy - a.rect.bottom).abs() < 1;
expect(onBorder, isTrue);
});
});
group('橡皮擦', () {