100J加个限制格式提示
This commit is contained in:
@ -79,6 +79,12 @@
|
||||
点击下方红色录制按钮开始录音,吐字清晰,语句流畅
|
||||
</view>
|
||||
</view>
|
||||
<!-- 上传语音的提示:仅支持 MP3 -->
|
||||
<view v-if="Status.pageType==='File'">
|
||||
<view class="tips" :class="{'displayNone':AudioData.tempFilePath}">
|
||||
仅支持 MP3 格式,请选择 .mp3 文件
|
||||
</view>
|
||||
</view>
|
||||
<!-- 录音、选择文件操作 -->
|
||||
<view class="footer" v-if="Status.pageType!=='Txt'">
|
||||
<view class="opt">
|
||||
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user