From bfa3d914e86051705615f6a7cb7537d8ac8ed242 Mon Sep 17 00:00:00 2001 From: wuxichen <17301714657@163.com> Date: Fri, 17 Oct 2025 10:14:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BD=95=E9=9F=B3=E4=B8=AD=20=E6=9A=82?= =?UTF-8?q?=E5=81=9C=E8=AF=AD=E9=9F=B3=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../translate/component/message/index.tsx | 53 +++---------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/projects/translate-h5/src/view/home/translate/component/message/index.tsx b/projects/translate-h5/src/view/home/translate/component/message/index.tsx index 05a66b0..1507105 100644 --- a/projects/translate-h5/src/view/home/translate/component/message/index.tsx +++ b/projects/translate-h5/src/view/home/translate/component/message/index.tsx @@ -17,11 +17,13 @@ function Index(props: DefinedProps) { const [isPlaying, setIsPlating] = useState(false); const [currentPlayingId, setCurrentPlayingId] = useState(); - // useEffect(() => { - // if (isRecording) { - // stopAllAudio(); - // } - // }, [isRecording]); + useEffect(() => { + if (isRecording && currentPlayingId) { + audioRefs.current[currentPlayingId].pause(); + audioRefs.current[currentPlayingId].currentTime = 0; + setCurrentPlayingId(undefined); + } + }, [isRecording, currentPlayingId]); const playAudio = (id: number, audioUrl: string) => { if (isRecording) { @@ -45,22 +47,7 @@ function Index(props: DefinedProps) { setCurrentPlayingId(undefined); } }; - // const stopAllAudio = () => { - // if (currentPlayingId && audioRefs.current[currentPlayingId]) { - // audioRefs.current[currentPlayingId].pause(); - // audioRefs.current[currentPlayingId].currentTime = 0; - // setIsPlating(false); - // setCurrentPlayingId(undefined); - // return; - // } - // Object.values(audioRefs.current).forEach((audio) => { - // if (!audio.paused) { - // audio.pause(); - // audio.currentTime = 0; - // } - // }); - // }; const renderAvatar = (item: Message) => { return ; }; @@ -132,32 +119,6 @@ function Index(props: DefinedProps) {
{item.contentDuration}''
{renderTranslateResult(item)} - {/* {item.isTranslating ? ( -
- - 翻译中... -
- ) : item.transStatus === 1 ? ( -
- {item.transResult?.length ? ( - item.transResult - ) : ( - - 未知语句 - refreshMessage(item.id, e)} size="12" fill="#333" /> - - )} -
- ) : ( - - 翻译失败,请重试 - refreshMessage(item.id, e)} size="12" fill="#333" /> - - //
- // 翻译失败,请重试 - // refreshMessage(item.id, e)} size="12" fill="#333" /> - //
- )} */} ))}