Compare commits
1 Commits
wuxichen
...
fc789b135f
| Author | SHA1 | Date | |
|---|---|---|---|
| fc789b135f |
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { Avatar, Divider, Space, SpinLoading, Toast } from "antd-mobile";
|
import { Avatar, Divider, Space, SpinLoading, Toast } from "antd-mobile";
|
||||||
import { VoiceIcon } from "@workspace/shared";
|
import { VoiceIcon } from "@workspace/shared";
|
||||||
import { Message } from "../../../types";
|
import { Message } from "../../../types";
|
||||||
@@ -14,16 +14,13 @@ interface DefinedProps {
|
|||||||
function Index(props: DefinedProps) {
|
function Index(props: DefinedProps) {
|
||||||
const { data, isRecording } = props;
|
const { data, isRecording } = props;
|
||||||
const audioRefs = useRef<{ [key: string]: HTMLAudioElement }>({});
|
const audioRefs = useRef<{ [key: string]: HTMLAudioElement }>({});
|
||||||
const [isPlaying, setIsPlating] = useState(false);
|
|
||||||
const [currentPlayingId, setCurrentPlayingId] = useState<number>();
|
const [currentPlayingId, setCurrentPlayingId] = useState<number>();
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (isRecording && currentPlayingId) {
|
// if (isRecording) {
|
||||||
audioRefs.current[currentPlayingId].pause();
|
// stopAllAudio();
|
||||||
audioRefs.current[currentPlayingId].currentTime = 0;
|
// }
|
||||||
setCurrentPlayingId(undefined);
|
// }, [isRecording]);
|
||||||
}
|
|
||||||
}, [isRecording, currentPlayingId]);
|
|
||||||
|
|
||||||
const playAudio = (id: number, audioUrl: string) => {
|
const playAudio = (id: number, audioUrl: string) => {
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
@@ -47,7 +44,22 @@ function Index(props: DefinedProps) {
|
|||||||
setCurrentPlayingId(undefined);
|
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) => {
|
const renderAvatar = (item: Message) => {
|
||||||
return <Avatar src={item.petAvatar || ""} style={{ "--border-radius": "32px" }} />;
|
return <Avatar src={item.petAvatar || ""} style={{ "--border-radius": "32px" }} />;
|
||||||
};
|
};
|
||||||
@@ -119,6 +131,32 @@ function Index(props: DefinedProps) {
|
|||||||
<div className="time">{item.contentDuration}''</div>
|
<div className="time">{item.contentDuration}''</div>
|
||||||
</div>
|
</div>
|
||||||
{renderTranslateResult(item)}
|
{renderTranslateResult(item)}
|
||||||
|
{/* {item.isTranslating ? (
|
||||||
|
<div className="translate">
|
||||||
|
<SpinLoading color="default" style={{ "--size": "12px" }} />
|
||||||
|
<span>翻译中...</span>
|
||||||
|
</div>
|
||||||
|
) : item.transStatus === 1 ? (
|
||||||
|
<div className="translate">
|
||||||
|
{item.transResult?.length ? (
|
||||||
|
item.transResult
|
||||||
|
) : (
|
||||||
|
<Space justify={"between"}>
|
||||||
|
<span>未知语句</span>
|
||||||
|
<Refresh onClick={(e) => refreshMessage(item.id, e)} size="12" fill="#333" />
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Space justify={"between"} className="translate">
|
||||||
|
<span>翻译失败,请重试</span>
|
||||||
|
<Refresh onClick={(e) => refreshMessage(item.id, e)} size="12" fill="#333" />
|
||||||
|
</Space>
|
||||||
|
// <div className="translate">
|
||||||
|
// <span> 翻译失败,请重试</span>
|
||||||
|
// <Refresh onClick={(e) => refreshMessage(item.id, e)} size="12" fill="#333" />
|
||||||
|
// </div>
|
||||||
|
)} */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user