diff --git a/web/src/components/AudioRecorder/index.tsx b/web/src/components/AudioRecorder/index.tsx index b3b87130..639a9109 100644 --- a/web/src/components/AudioRecorder/index.tsx +++ b/web/src/components/AudioRecorder/index.tsx @@ -2,10 +2,12 @@ * @Author: ZhaoYing * @Date: 2026-02-06 21:11:51 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-16 18:06:00 + * @Last Modified time: 2026-03-17 18:39:09 */ import { type FC, useRef, useState } from 'react' import RecordRTC from 'recordrtc' +import { App } from 'antd' +import { useTranslation } from 'react-i18next'; import { fileUploadUrlWithoutApiPrefix } from '@/api/fileStorage' import { request } from '@/utils/request' @@ -20,6 +22,7 @@ interface AudioRecorderProps { /** Additional config passed to the upload request */ requestConfig?: Record; disabled?: boolean; + maxSize?: number; } const AudioRecorder: FC = ({ @@ -27,8 +30,11 @@ const AudioRecorder: FC = ({ className = '', action = fileUploadUrlWithoutApiPrefix, requestConfig = {}, - disabled = false + disabled = false, + maxSize, }) => { + const { message } = App.useApp() + const { t } = useTranslation(); // Whether the recorder is currently capturing audio const [isRecording, setIsRecording] = useState(false) // Holds the RecordRTC instance across renders @@ -57,6 +63,12 @@ const AudioRecorder: FC = ({ recorderRef.current.stopRecording(() => { const blob = recorderRef.current!.getBlob() const url = recorderRef.current!.toURL() + + if (maxSize && blob.size > maxSize * 1024 * 1024) { + message.error(t('common.fileSizeTip', { size: maxSize })); + return + } + const formData = new FormData() formData.append('file', blob, `recording_${Date.now()}.webm`) request diff --git a/web/src/components/Chat/ChatToolbar.tsx b/web/src/components/Chat/ChatToolbar.tsx index 1d368c30..6a316bd5 100644 --- a/web/src/components/Chat/ChatToolbar.tsx +++ b/web/src/components/Chat/ChatToolbar.tsx @@ -1,8 +1,8 @@ /* * @Author: ZhaoYing * @Date: 2026-03-17 14:22:25 - * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-17 14:22:25 + * @Last Modified by: ZhaoYing + * @Last Modified time: 2026-03-17 18:39:49 */ // Toolbar component for chat input area, supporting file upload, audio recording, and variable configuration import { useRef, forwardRef, useImperativeHandle, type ReactNode, useEffect } from 'react' @@ -151,8 +151,6 @@ const ChatToolbar = forwardRef(({ }) } - console.log('queryValues', queryValues) - return (
@@ -183,6 +181,7 @@ const ChatToolbar = forwardRef(({ action={uploadAction} requestConfig={uploadRequestConfig} onRecordingComplete={handleRecordingComplete} + maxSize={file_upload?.audio_max_size_mb} /> diff --git a/web/src/views/Conversation/index.tsx b/web/src/views/Conversation/index.tsx index 3e4833de..7a57c615 100644 --- a/web/src/views/Conversation/index.tsx +++ b/web/src/views/Conversation/index.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-03 16:58:03 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-17 15:39:17 + * @Last Modified time: 2026-03-17 18:30:58 */ /** * Conversation Page @@ -369,7 +369,7 @@ const Conversation: FC = () => { }} extra={ <> - {features.web_search?.enabled && + {features?.web_search?.enabled &&