From 1958273d55fa82bb85ef5dd5cf9af92956f7ede3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=9A=E8=BE=B0=E5=85=88=E7=94=9F?= Date: Thu, 5 Dec 2024 22:09:04 +0800 Subject: [PATCH] 1 --- .../Definition/Designer/components/Toolbar/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/Workflow/Definition/Designer/components/Toolbar/index.tsx b/frontend/src/pages/Workflow/Definition/Designer/components/Toolbar/index.tsx index c8cd3895..f54e41b7 100644 --- a/frontend/src/pages/Workflow/Definition/Designer/components/Toolbar/index.tsx +++ b/frontend/src/pages/Workflow/Definition/Designer/components/Toolbar/index.tsx @@ -136,14 +136,19 @@ const Toolbar: React.FC = ({ graph }) => { // 缩放画布 const zoom = (delta: number) => { if (!graph) return; - const zoom = graph.zoom(); - graph.zoom(zoom + delta); + const currentZoom = graph.zoom(); + const nextZoom = delta > 0 + ? Math.min(2, currentZoom + 0.1) // 放大,最大2倍 + : Math.max(0.5, currentZoom - 0.1); // 缩小,最小0.5倍 + graph.zoomTo(nextZoom); + graph.centerContent(); // 居中显示内容 }; // 适应画布 const fitContent = () => { if (!graph) return; - graph.zoomToFit({ padding: 20 }); + graph.zoomToFit({ padding: 20, maxScale: 2 }); + graph.centerContent(); }; // 实际大小