()
| 250 | |
| 251 | // 重置视图到初始适应大小 |
| 252 | const handleResetView = () => { |
| 253 | const canvas = canvasRef.current |
| 254 | const container = containerRef.current |
| 255 | if (!canvas || !container) return |
| 256 | |
| 257 | const containerWidth = container.clientWidth - 40 |
| 258 | const containerHeight = container.clientHeight - 40 |
| 259 | const scaleX = containerWidth / canvas.width |
| 260 | const scaleY = containerHeight / canvas.height |
| 261 | const initialScale = Math.min(scaleX, scaleY, 1) |
| 262 | |
| 263 | setScale(initialScale) |
| 264 | setOffset({ x: 0, y: 0 }) |
| 265 | } |
| 266 | |
| 267 | // 绘制箭头的辅助函数 |
| 268 | const drawArrow = ( |
nothing calls this directly
no outgoing calls
no test coverage detected