diff --git a/apps/web/src/pages/voices/components/UploadVoiceModal.tsx b/apps/web/src/pages/voices/components/UploadVoiceModal.tsx index 75aaff541..56928dbb7 100755 --- a/apps/web/src/pages/voices/components/UploadVoiceModal.tsx +++ b/apps/web/src/pages/voices/components/UploadVoiceModal.tsx @@ -1,24 +1,13 @@ import React from "react" -import { UploadOutlined, SoundOutlined } from "@ant-design/icons" -import { Modal, Upload, message } from "antd" -import { type VoiceGender } from "@/pages/voices/types" -import { formatFileSize } from "@/pages/voices/utils/format" - -export interface UploadVoiceModalProps { - open: boolean - uploadFile: File | null - uploadName: string - uploadGender: VoiceGender - uploadDesc: string - uploadProgress: number | null - onClose: () => void - onFileSelect: (file: File) => void - onFileRemove: () => void - onNameChange: (name: string) => void - onGenderChange: (gender: VoiceGender) => void - onDescChange: (desc: string) => void - onUpload: () => void -} +import { Modal } from "antd" +import { + FileUploadZone, + FileInfoCard, + UploadProgress, + FormFields, + ActionButtons, +} from "./upload-voice-modal" +import type { UploadVoiceModalProps } from "./upload-voice-modal" /** 上传音频弹窗 */ const UploadVoiceModal: React.FC = ({ @@ -36,17 +25,20 @@ const UploadVoiceModal: React.FC = ({ onDescChange, onUpload, }) => { + const uploading = uploadProgress !== null + const canUpload = !!uploadFile && !!uploadName.trim() + return ( { - if (uploadProgress !== null) return // 上传中不可关闭 + if (uploading) return // 上传中不可关闭 onClose() }} footer={null} width={520} - maskClosable={uploadProgress === null} + maskClosable={!uploading} >
= ({ }} > {/* 拖拽上传区 */} - { - onFileSelect(file) - return false - }} - onRemove={() => { - onFileRemove() - }} - showUploadList={false} - disabled={uploadProgress !== null} - > -

- -

-

- 点击或拖拽音频文件到此处 -

-

- 支持 MP3、WAV、AAC、FLAC 等格式,最大 200MB -

-
+ {/* 已选文件信息 */} - {uploadFile && ( -
- -
-
- {uploadFile.name} -
-
- {formatFileSize(uploadFile.size)} -
-
-
- )} + {uploadFile && } {/* 上传进度 */} - {uploadProgress !== null && ( -
-
- {uploadProgress}% -
-
- {uploadProgress < 100 ? "上传中..." : "处理中..."} -
-
-
-
-
- )} + {uploadProgress !== null && } - {/* 名称 */} -
-
- 素材名称 -
- onNameChange(e.target.value)} - placeholder="输入素材名称" - maxLength={100} - disabled={uploadProgress !== null} - style={{ - width: "100%", - padding: "8px 12px", - border: "1px solid var(--border-color)", - borderRadius: 8, - fontSize: 13, - background: "var(--bg-primary)", - color: "var(--text-primary)", - outline: "none", - }} - /> -
- - {/* 性别选择 */} -
-
- 音色性别 -
-
- {(["female", "male", "child"] as VoiceGender[]).map((g) => ( - - ))} -
-
- - {/* 描述 */} -
-
- 音色描述(可选) -
-