From 5c5249cb707515f26ef1459c06cc82bb8f699b65 Mon Sep 17 00:00:00 2001 From: chiyi Date: Mon, 12 Oct 2026 14:28:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(canvas):=20=E9=80=82=E5=BA=94=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=BC=A9=E6=94=BE=E5=AF=B9=E9=BD=90=E5=88=B010%?= =?UTF-8?q?=E6=A1=A3=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/canvas/CanvasStage.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/canvas/CanvasStage.vue b/frontend/src/components/canvas/CanvasStage.vue index 530ec0b..0de29c4 100644 --- a/frontend/src/components/canvas/CanvasStage.vue +++ b/frontend/src/components/canvas/CanvasStage.vue @@ -682,9 +682,12 @@ function fitToContent() { const bw = Math.max(1, x2 - x1 + pad * 2) const bh = Math.max(1, y2 - y1 + pad * 2) const s = Math.min(sw / bw, sh / bh, 1.2) // 期望的有效缩放 - vp.scale = Math.min(MAX_SCALE, Math.max(MIN_SCALE, s / BASE_SCALE)) - vp.x = sw / 2 - (x1 - pad + bw / 2) * s - vp.y = sh / 2 - (y1 - pad + bh / 2) * s + // 对齐 10% 档位:向下取整保证内容完整可见 + const target = Math.min(MAX_SCALE, Math.max(MIN_SCALE, Math.floor(s / BASE_SCALE * 10 + 1e-6) / 10)) + const eff = target * BASE_SCALE + vp.scale = target + vp.x = sw / 2 - (x1 - pad + bw / 2) * eff + vp.y = sh / 2 - (y1 - pad + bh / 2) * eff notifyViewport() } function selectedIds() {