diff --git a/pages/100J/audioManager/Recording.vue b/pages/100J/audioManager/Recording.vue index a18be46..764d71b 100644 --- a/pages/100J/audioManager/Recording.vue +++ b/pages/100J/audioManager/Recording.vue @@ -79,12 +79,6 @@ 点击下方红色录制按钮开始录音,吐字清晰,语句流畅 - - - - 仅支持 MP3 格式,请选择 .mp3 文件 - - @@ -472,11 +466,16 @@ this.showMsg("请先录制或选择音频文件"); return; } - // 仅支持 MP3 格式 - const uploadFilePath = this.AudioData.tempFilePath; - if (!uploadFilePath.toLowerCase().endsWith('.mp3')) { - this.showMsg("仅支持 MP3 格式,请选择 .mp3 文件"); - return; + // 检查文件扩展名 + const validExtensions = ['.mp3', '.wav', '.aac', '.m4a']; + let uploadFilePath = this.AudioData.tempFilePath; + const hasValidExtension = validExtensions.some(ext => + uploadFilePath.toLowerCase().endsWith(ext) + ); + if (!hasValidExtension) { + // 如果没有有效扩展名,添加.mp3扩展名 + uploadFilePath = uploadFilePath + '.mp3'; + console.log("自动添加.mp3扩展名,新路径:", uploadFilePath); } console.log("上传文件路径:", uploadFilePath); @@ -754,15 +753,12 @@ handleUploadCallback(res) { console.log("选择文件:", res); if (res && res.data) { - if (this.Status.pageType === 'File') { //文件上传,仅支持 MP3 - const file = res.data[0]; - const name = (file.name || '').toLowerCase(); - const isMp3 = name.endsWith('.mp3') || (file.type || '').includes('mpeg'); - if (isMp3) { - this.cEdit.name = file.name; - this.playInit(file.tempFilePath); + if (this.Status.pageType === 'File') { //文件上传 + if (res.data[0].type.indexOf('audio') > -1) { + this.cEdit.name = res.data[0].name; + this.playInit(res.data[0].tempFilePath); } else { - this.showMsg("仅支持 MP3 格式,请选择 .mp3 文件"); + this.showMsg("只能选择音频文件"); } return; } @@ -940,10 +936,7 @@ }); }, checkFile() { - const config = this.Status.pageType === 'File' - ? { extension: ['.mp3'] } - : { extension: ['.txt', '.doc', '.docx'] }; - this.$refs.XeUpload.upload('file', config); + this.$refs.XeUpload.upload('file'); }, toggleRecord() { if (this.Status.recoderIntval) {