From 4d87590d4c755bebd5ec0e15bd9f0f1968846dba Mon Sep 17 00:00:00 2001 From: jingrow Date: Mon, 4 May 2026 18:29:27 +0800 Subject: [PATCH] =?UTF-8?q?whiteboard=E7=94=BB=E7=9F=A9=E5=BD=A2=E5=9C=86?= =?UTF-8?q?=E5=BD=A2=E8=8F=B1=E5=BD=A2=E6=97=B6=E5=A2=9E=E5=8A=A0=E6=8C=89?= =?UTF-8?q?=E4=BD=8Fshift=E6=97=B6=E7=94=BB=E6=AD=A3=E6=96=B9=E5=BD=A2?= =?UTF-8?q?=E6=AD=A3=E5=9C=86=E6=88=96=E6=AD=A3=E8=8F=B1=E5=BD=A2=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interaction/BoardInteractionManager.ts | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/frontend/src/core/features/whiteboard/interaction/BoardInteractionManager.ts b/frontend/src/core/features/whiteboard/interaction/BoardInteractionManager.ts index aa0be9b3d..ada391a45 100644 --- a/frontend/src/core/features/whiteboard/interaction/BoardInteractionManager.ts +++ b/frontend/src/core/features/whiteboard/interaction/BoardInteractionManager.ts @@ -227,7 +227,7 @@ export class BoardInteractionManager { this.updateRendererSelection() } else if (this.state.isDrawing && this.state.drawingStartElement) { // 更新正在绘制的形状大小 - this.handleDrawingMove(worldPos) + this.handleDrawingMove(worldPos, e) } else if (this.state.isFreehanding) { this.handleFreehandMove(worldPos) } else if (this.currentTool === 'select') { @@ -690,7 +690,7 @@ export class BoardInteractionManager { } /** 形状绘制 - 移动 */ - private handleDrawingMove(worldPos: Point): void { + private handleDrawingMove(worldPos: Point, e: MouseEvent): void { if (!this.state.drawingStartElement || !this.state.draggedElementId) return const start = this.state.drawingStartElement const el = this.board.getElement(this.state.draggedElementId) @@ -705,14 +705,25 @@ export class BoardInteractionManager { arrow.y = Math.min(start.y, worldPos.y) arrow.width = Math.max(Math.abs(worldPos.x - start.x), 1) arrow.height = Math.max(Math.abs(worldPos.y - start.y), 1) - } else { + } else if (el.type === 'rectangle' || el.type === 'ellipse' || el.type === 'diamond' || el.type === 'sticky-note') { // 矩形/椭圆/菱形/便利贴:标准包围盒绘制 - const x = Math.min(start.x, worldPos.x) - const y = Math.min(start.y, worldPos.y) - const width = Math.abs(worldPos.x - start.x) - const height = Math.abs(worldPos.y - start.y) + let rawW = Math.abs(worldPos.x - start.x) + let rawH = Math.abs(worldPos.y - start.y) + let x = Math.min(start.x, worldPos.x) + let y = Math.min(start.y, worldPos.y) + + if (e.shiftKey && rawW > 0 && rawH > 0) { + // Shift 约束长宽比 → 正方形/正圆 + const size = Math.max(rawW, rawH) + rawW = size + rawH = size + // 保持起点为包围盒左上角 + x = start.x <= worldPos.x ? start.x : start.x - size + y = start.y <= worldPos.y ? start.y : start.y - size + } + this.board.updateElementPosition(el.id, x, y) - this.board.updateElementSize(el.id, Math.max(width, 1), Math.max(height, 1)) + this.board.updateElementSize(el.id, rawW, rawH) } this.renderer.forceRedraw()