feat: 头像
This commit is contained in:
@@ -10,7 +10,7 @@ import { useUploadAudio } from "@/api/translate";
|
||||
import dogSvg from "@/assets/translate/dog.svg";
|
||||
import catSvg from "@/assets/translate/cat.svg";
|
||||
import pigSvg from "@/assets/translate/pig.svg";
|
||||
import { MoreTwo } from "@icon-park/react";
|
||||
import { MoreTwo, Petrol } from "@icon-park/react";
|
||||
import SearchCom from "./component/search";
|
||||
interface DefinedProps {
|
||||
searchVisible: boolean;
|
||||
@@ -41,15 +41,12 @@ function Index(props: DefinedProps) {
|
||||
fetchInitialMessages();
|
||||
}, []);
|
||||
|
||||
|
||||
// 添加初始化数据的逻辑
|
||||
const fetchInitialMessages = async () => {
|
||||
try {
|
||||
// 这里替换为实际的API调用
|
||||
// const response = await fetch('/api/messages');
|
||||
const response = await getDialog();
|
||||
// console.log(response);
|
||||
|
||||
const initialMessages: Message[] = response.data?.data?.messages || [];
|
||||
|
||||
setDialogId(response.data?.data?.dialogId);
|
||||
@@ -65,11 +62,10 @@ function Index(props: DefinedProps) {
|
||||
//完成录音
|
||||
const onRecordingComplete = useCallback(
|
||||
(audioUrl: string, actualDuration: number, formData: FormData) => {
|
||||
console.log(audioUrl, "audioUrl")
|
||||
console.log(audioUrl, "audioUrl");
|
||||
const newMessage: Message = {
|
||||
id: Date.now(),
|
||||
contentText: audioUrl,
|
||||
petName: "匹配档案中。。。",
|
||||
contentDuration: actualDuration,
|
||||
isTranslating: true,
|
||||
};
|
||||
@@ -77,7 +73,7 @@ function Index(props: DefinedProps) {
|
||||
setMessages((prev) => [...prev, newMessage]);
|
||||
setTimeout(() => {
|
||||
onTranslateAudio(formData, newMessage.id);
|
||||
}, 1000);
|
||||
}, 500);
|
||||
|
||||
Toast.show("语音已发送");
|
||||
},
|
||||
@@ -90,7 +86,6 @@ function Index(props: DefinedProps) {
|
||||
try {
|
||||
const response = await uploadAudio(formData);
|
||||
const translatedData = response.data;
|
||||
console.log(translatedData, "translatedText");
|
||||
|
||||
if (translatedData.data.transStatus) {
|
||||
setMessages((prev) =>
|
||||
@@ -111,7 +106,9 @@ function Index(props: DefinedProps) {
|
||||
? {
|
||||
...msg,
|
||||
id: translatedData.data.id,
|
||||
petName: "未知宠物",
|
||||
transStatus: translatedData.data.transStatus,
|
||||
createTime: translatedData.data.createTime,
|
||||
isTranslating: false,
|
||||
}
|
||||
: msg
|
||||
@@ -183,7 +180,7 @@ function Index(props: DefinedProps) {
|
||||
isRecording={isRecording}
|
||||
onSetIsRecording={onSetIsRecording}
|
||||
/>
|
||||
<FloatingMenu menuItems={menuItems} value={currentLanguage} onChange={onLanguage} />
|
||||
{/* <FloatingMenu menuItems={menuItems} value={currentLanguage} onChange={onLanguage} /> */}
|
||||
<XPopup
|
||||
title="选择翻译语种"
|
||||
visible={visible}
|
||||
|
||||
Reference in New Issue
Block a user