From 444b3b35ace446bae60b9332f8706e09477aab28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=BE=AE=E4=B8=80=E7=AC=91?= <709648985@qq.com> Date: Thu, 19 Mar 2026 15:46:53 +0800 Subject: [PATCH] =?UTF-8?q?100J=E5=8A=A0=E4=B8=AA=E9=99=90=E5=88=B6?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/100J/audioManager/Recording.vue | 39 ++++++++++++++++----------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/pages/100J/audioManager/Recording.vue b/pages/100J/audioManager/Recording.vue index 764d71b..a18be46 100644 --- a/pages/100J/audioManager/Recording.vue +++ b/pages/100J/audioManager/Recording.vue @@ -79,6 +79,12 @@ 点击下方红色录制按钮开始录音,吐字清晰,语句流畅 + + + + 仅支持 MP3 格式,请选择 .mp3 文件 + + @@ -466,16 +472,11 @@ this.showMsg("请先录制或选择音频文件"); 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); + // 仅支持 MP3 格式 + const uploadFilePath = this.AudioData.tempFilePath; + if (!uploadFilePath.toLowerCase().endsWith('.mp3')) { + this.showMsg("仅支持 MP3 格式,请选择 .mp3 文件"); + return; } console.log("上传文件路径:", uploadFilePath); @@ -753,12 +754,15 @@ handleUploadCallback(res) { console.log("选择文件:", res); if (res && res.data) { - 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); + 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); } else { - this.showMsg("只能选择音频文件"); + this.showMsg("仅支持 MP3 格式,请选择 .mp3 文件"); } return; } @@ -936,7 +940,10 @@ }); }, checkFile() { - this.$refs.XeUpload.upload('file'); + const config = this.Status.pageType === 'File' + ? { extension: ['.mp3'] } + : { extension: ['.txt', '.doc', '.docx'] }; + this.$refs.XeUpload.upload('file', config); }, toggleRecord() { if (this.Status.recoderIntval) {