/* * @Author: ZhaoYing * @Date: 2026-03-05 * @Last Modified by: ZhaoYing * @Last Modified time: 2026-03-11 15:42:13 */ import { forwardRef, useImperativeHandle, useState } from 'react'; import { Form, Radio, InputNumber, Flex, Switch, Row, Col } from 'antd'; import { useTranslation } from 'react-i18next'; import clsx from 'clsx'; import RbModal from '@/components/RbModal'; import type { FunConfigForm } from '../../types' interface FileUploadSettingModalRef { handleOpen: (values?: FileUploadSettings) => void; handleClose: () => void; } interface FileUploadSettings extends Omit {} interface FileUploadSettingModalProps { onSave: (values: FileUploadSettings) => void; } const fileTypeOptions = [ { type: 'document', icon:
, formats: 'TXT, MD, MDX, MARKDOWN, PDF, DOC, DOCX', defaultMaxCount: 1, defaultMaxSize: 2 }, { type: 'image', icon:
, formats: 'JPG, JPEG, PNG, GIF, WEBP, SVG', defaultMaxCount: 1, defaultMaxSize: 2 }, { type: 'audio', icon:
, formats: 'MP3, M4A, WAV, AMR, MPGA', defaultMaxCount: 1, defaultMaxSize: 2 }, { type: 'video', icon:
, formats: 'MP4, MOV, MPEG, WEBM', defaultMaxCount: 1, defaultMaxSize: 2 }, ]; const FileUploadSettingModal = forwardRef(({ onSave, }, ref) => { const { t } = useTranslation(); const [visible, setVisible] = useState(false); const [form] = Form.useForm(); const values = Form.useWatch([], form) const handleClose = () => { setVisible(false); form.resetFields(); }; const handleOpen = (values?: FileUploadSettings) => { setVisible(true); // if (values) { // form.setFieldsValue(values); // } }; const handleSave = async () => { const values = await form.validateFields(); onSave(values); handleClose(); }; useImperativeHandle(ref, () => ({ handleOpen, handleClose })); return (
({ type: opt.type, enabled: false, maxCount: opt.defaultMaxCount, maxSize: opt.defaultMaxSize })) }} > {t('application.local')} URL {t('application.both')}
{t('application.maxCount')}
{(fields) => ( {fields.map((field, index) => { const option = fileTypeOptions[index]; const isEnabled = values?.fileTypes?.[index]?.enabled; return (
{option.icon}
{t(`application.${option.type}`)}
{option.formats}
{isEnabled && (
{t('application.singleMaxSize')}:
)}
); })}
)}
); }); export default FileUploadSettingModal;