100J加个限制格式提示
This commit is contained in:
@ -79,6 +79,12 @@
|
|||||||
点击下方红色录制按钮开始录音,吐字清晰,语句流畅
|
点击下方红色录制按钮开始录音,吐字清晰,语句流畅
|
||||||
</view>
|
</view>
|
||||||
</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="footer" v-if="Status.pageType!=='Txt'">
|
||||||
<view class="opt">
|
<view class="opt">
|
||||||
@ -466,16 +472,11 @@
|
|||||||
this.showMsg("请先录制或选择音频文件");
|
this.showMsg("请先录制或选择音频文件");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 检查文件扩展名
|
// 仅支持 MP3 格式
|
||||||
const validExtensions = ['.mp3', '.wav', '.aac', '.m4a'];
|
const uploadFilePath = this.AudioData.tempFilePath;
|
||||||
let uploadFilePath = this.AudioData.tempFilePath;
|
if (!uploadFilePath.toLowerCase().endsWith('.mp3')) {
|
||||||
const hasValidExtension = validExtensions.some(ext =>
|
this.showMsg("仅支持 MP3 格式,请选择 .mp3 文件");
|
||||||
uploadFilePath.toLowerCase().endsWith(ext)
|
return;
|
||||||
);
|
|
||||||
if (!hasValidExtension) {
|
|
||||||
// 如果没有有效扩展名,添加.mp3扩展名
|
|
||||||
uploadFilePath = uploadFilePath + '.mp3';
|
|
||||||
console.log("自动添加.mp3扩展名,新路径:", uploadFilePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("上传文件路径:", uploadFilePath);
|
console.log("上传文件路径:", uploadFilePath);
|
||||||
@ -753,12 +754,15 @@
|
|||||||
handleUploadCallback(res) {
|
handleUploadCallback(res) {
|
||||||
console.log("选择文件:", res);
|
console.log("选择文件:", res);
|
||||||
if (res && res.data) {
|
if (res && res.data) {
|
||||||
if (this.Status.pageType === 'File') { //文件上传
|
if (this.Status.pageType === 'File') { //文件上传,仅支持 MP3
|
||||||
if (res.data[0].type.indexOf('audio') > -1) {
|
const file = res.data[0];
|
||||||
this.cEdit.name = res.data[0].name;
|
const name = (file.name || '').toLowerCase();
|
||||||
this.playInit(res.data[0].tempFilePath);
|
const isMp3 = name.endsWith('.mp3') || (file.type || '').includes('mpeg');
|
||||||
|
if (isMp3) {
|
||||||
|
this.cEdit.name = file.name;
|
||||||
|
this.playInit(file.tempFilePath);
|
||||||
} else {
|
} else {
|
||||||
this.showMsg("只能选择音频文件");
|
this.showMsg("仅支持 MP3 格式,请选择 .mp3 文件");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -936,7 +940,10 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
checkFile() {
|
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() {
|
toggleRecord() {
|
||||||
if (this.Status.recoderIntval) {
|
if (this.Status.recoderIntval) {
|
||||||
|
|||||||
Reference in New Issue
Block a user