语音射别修复
This commit is contained in:
@@ -65,6 +65,26 @@ const centerIndex = ref(0);
|
||||
// 动画帧ID
|
||||
let animationId = null;
|
||||
|
||||
// 为小程序环境提供requestAnimationFrame兼容
|
||||
const requestAnimationFramePolyfill = (callback) => {
|
||||
// #ifdef MP-WEIXIN
|
||||
return setTimeout(callback, 16); // 约60fps
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
return requestAnimationFrame(callback);
|
||||
// #endif
|
||||
};
|
||||
|
||||
// 为小程序环境提供cancelAnimationFrame兼容
|
||||
const cancelAnimationFramePolyfill = (id) => {
|
||||
// #ifdef MP-WEIXIN
|
||||
clearTimeout(id);
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
cancelAnimationFrame(id);
|
||||
// #endif
|
||||
};
|
||||
|
||||
// 格式化显示时间
|
||||
const formattedTime = computed(() => {
|
||||
const mins = Math.floor(props.recordingTime / 60)
|
||||
@@ -125,7 +145,7 @@ const updateWaveform = () => {
|
||||
}
|
||||
}
|
||||
|
||||
animationId = requestAnimationFrame(updateWaveform);
|
||||
animationId = requestAnimationFramePolyfill(updateWaveform);
|
||||
};
|
||||
|
||||
// 更新单个波形条
|
||||
@@ -157,14 +177,14 @@ const updateWaveBar = (index, value) => {
|
||||
// 开始动画
|
||||
const startAnimation = () => {
|
||||
if (!animationId) {
|
||||
animationId = requestAnimationFrame(updateWaveform);
|
||||
animationId = requestAnimationFramePolyfill(updateWaveform);
|
||||
}
|
||||
};
|
||||
|
||||
// 停止动画
|
||||
const stopAnimation = () => {
|
||||
if (animationId) {
|
||||
cancelAnimationFrame(animationId);
|
||||
cancelAnimationFramePolyfill(animationId);
|
||||
animationId = null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user