Refactor IndexController to return a simple message instead of an iframe. Update AudioRecorder and SimpleFileUpload components to include file name in the upload callback. Modify MessageEnter component to handle new file structure and improve message handling logic. Clean up unused state and enhance video message rendering. Update websocket message management to handle message IDs more robustly.

This commit is contained in:
超级老白兔
2025-11-08 15:13:20 +08:00
parent f9c08b6091
commit 35c9369d3d
7 changed files with 162 additions and 186 deletions

View File

@@ -10,7 +10,11 @@ import {
import { uploadFile } from "@/api/common";
interface AudioRecorderProps {
onAudioUploaded: (audioData: { url: string; durationMs: number }) => void;
onAudioUploaded: (audioData: {
url: string;
name: string;
durationMs?: number;
}) => void;
className?: string;
disabled?: boolean;
maxDuration?: number; // 最大录音时长(秒)
@@ -206,6 +210,7 @@ const AudioRecorder: React.FC<AudioRecorderProps> = ({
// 调用回调函数传递音频URL和时长毫秒
onAudioUploaded({
url: filePath,
name: audioFile.name,
durationMs: recordingTime * 1000, // 将秒转换为毫秒
});

View File

@@ -3,7 +3,7 @@ import React, { useRef } from "react";
import { message } from "antd";
interface SimpleFileUploadProps {
onFileUploaded?: (filePath: string) => void;
onFileUploaded?: (filePath: { name: string; url: string }) => void;
maxSize?: number; // 最大文件大小(MB)
type?: number; // 1: 图片, 2: 视频, 3: 音频, 4: 文件
slot?: React.ReactNode;
@@ -51,7 +51,10 @@ const SimpleFileUpload: React.FC<SimpleFileUploadProps> = ({
try {
const fileUrl = await uploadFile(file);
onFileUploaded?.(fileUrl);
onFileUploaded?.({
name: file.name,
url: fileUrl,
});
message.success("文件上传成功");
} catch (error: any) {
console.error("文件上传失败:", error);