hookehuyr

fix 图片旋转时添加节流控制变量

...@@ -418,7 +418,12 @@ const scaleImage = (factor) => { ...@@ -418,7 +418,12 @@ const scaleImage = (factor) => {
418 const imageRotation = ref(0); 418 const imageRotation = ref(0);
419 419
420 // 修改 rotateMap 方法,只旋转图片 420 // 修改 rotateMap 方法,只旋转图片
421 +// 添加节流控制变量
422 +const isRotating = ref(false);
423 +
421 const rotateMap = (deltaAngle) => { 424 const rotateMap = (deltaAngle) => {
425 + // 如果正在旋转中,直接返回
426 + if (isRotating.value) return;
422 if (!imageLayer.value || !imageURL.value || !bounds.value) return; 427 if (!imageLayer.value || !imageURL.value || !bounds.value) return;
423 428
424 // 计算新的旋转角度 429 // 计算新的旋转角度
...@@ -434,6 +439,9 @@ const rotateMap = (deltaAngle) => { ...@@ -434,6 +439,9 @@ const rotateMap = (deltaAngle) => {
434 return; // 如果超出范围则不执行旋转 439 return; // 如果超出范围则不执行旋转
435 } 440 }
436 441
442 + // 设置正在旋转标志
443 + isRotating.value = true;
444 +
437 imageRotation.value = newRotation; 445 imageRotation.value = newRotation;
438 446
439 const img = new Image(); 447 const img = new Image();
...@@ -508,6 +516,11 @@ const rotateMap = (deltaAngle) => { ...@@ -508,6 +516,11 @@ const rotateMap = (deltaAngle) => {
508 516
509 map.value.add(imageLayer.value); 517 map.value.add(imageLayer.value);
510 bounds.value = newBounds; 518 bounds.value = newBounds;
519 +
520 + // 1秒后重置旋转状态
521 + setTimeout(() => {
522 + isRotating.value = false;
523 + }, 1000);
511 }; 524 };
512 }; 525 };
513 526
......