Compare commits

..

1 Commits

Author SHA1 Message Date
fc789b135f feat: 删除未使用 2025-10-17 10:16:21 +08:00

View File

@@ -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 { VoiceIcon } from "@workspace/shared";
import { Message } from "../../../types";
@@ -14,16 +14,13 @@ interface DefinedProps {
function Index(props: DefinedProps) {
const { data, isRecording } = props;
const audioRefs = useRef<{ [key: string]: HTMLAudioElement }>({});
const [isPlaying, setIsPlating] = useState(false);
const [currentPlayingId, setCurrentPlayingId] = useState<number>();
useEffect(() => {
if (isRecording && currentPlayingId) {
audioRefs.current[currentPlayingId].pause();
audioRefs.current[currentPlayingId].currentTime = 0;
setCurrentPlayingId(undefined);
}
}, [isRecording, currentPlayingId]);
// useEffect(() => {
// if (isRecording) {
// stopAllAudio();
// }
// }, [isRecording]);
const playAudio = (id: number, audioUrl: string) => {
if (isRecording) {
@@ -47,7 +44,22 @@ 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 <Avatar src={item.petAvatar || ""} style={{ "--border-radius": "32px" }} />;
};
@@ -119,6 +131,32 @@ function Index(props: DefinedProps) {
<div className="time">{item.contentDuration}''</div>
</div>
{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>
))}