Commit a19b27ac authored by limingzhe's avatar limingzhe
parents 3ebf9844 b68f5171
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
Record Audio Record Audio
</div> </div>
<nz-upload <nz-upload
[nzAccept] = "'.mp3'" [nzAccept] = "'.mp3,.m4a,.wav,.ogg'"
[nzShowUploadList]="false" [nzShowUploadList]="false"
[nzAction]="uploadUrl" [nzAction]="uploadUrl"
[nzData]="uploadData" [nzData]="uploadData"
......
...@@ -214,7 +214,8 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -214,7 +214,8 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
case 'success': case 'success':
this.isUploading = false; this.isUploading = false;
let url = info.file.response.url; let url = info.file.response.url;
url = url.substring(0, url.lastIndexOf(".")) + "_l.mp3"; // 保留原始文件格式,只添加_l前缀
url = this.replaceAudioUrl(url);
info.file.response.url = url; info.file.response.url = url;
this.uploadSuccess(info.file.response); this.uploadSuccess(info.file.response);
this.audioUploaded.emit(info.file.response); this.audioUploaded.emit(info.file.response);
...@@ -225,13 +226,20 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -225,13 +226,20 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
break; break;
} }
} }
replaceAudioUrl(url: string) {
const ext = url.substring(url.lastIndexOf(".")).toLowerCase();
if(ext === ".mp3") {
url = url.substring(0, url.lastIndexOf(".")) + "_l.mp3";
}
return url;
}
checkSelectFile(file: any) { checkSelectFile(file: any) {
if (!file) { if (!file) {
return; return;
} }
const isAudio = ['audio/mp3', 'audio/wav', 'audio/ogg'].includes(file.type); const isAudio = ['audio/mp3', 'audio/wav', 'audio/ogg', 'audio/m4a', 'audio/x-m4a'].includes(file.type);
if (!isAudio) { if (!isAudio) {
this.nzMessageService.error('You can only upload Audio file ( mp3 | wav |ogg)'); this.nzMessageService.error('You can only upload Audio file ( mp3 | wav | ogg | m4a )');
return; return;
} }
const delta = 25; const delta = 25;
...@@ -277,7 +285,8 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -277,7 +285,8 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
} }
linkInputed (url, name) { linkInputed (url, name) {
url = url.substring(0, url.lastIndexOf(".")) + "_l.mp3";
url = this.replaceAudioUrl(url);
this.audioUrl = url; this.audioUrl = url;
this.audioUploaded.emit({url}); this.audioUploaded.emit({url});
this.audioName.emit(name); this.audioName.emit(name);
...@@ -298,7 +307,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -298,7 +307,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
if (url.indexOf("teach")<0 || url.indexOf("cdn")<0) { if (url.indexOf("teach")<0 || url.indexOf("cdn")<0) {
return; return;
} }
const white = [".mp3"]; const white = [".mp3", ".m4a", ".wav", ".ogg"];
if (!white.includes(url.substr(url.lastIndexOf(".")))) { if (!white.includes(url.substr(url.lastIndexOf(".")))) {
return; return;
} }
......
...@@ -102,10 +102,10 @@ ...@@ -102,10 +102,10 @@
</span> </span>
<div style="width: auto; display: flex; align-items: center;"> <div style="width: auto; display: flex; align-items: center;">
<label style="margin-right: 10px; font-size: 14px;"> <label style="margin-right: 10px; font-size: 14px;">
<input type="radio" [(ngModel)]="word.displayType" [value]="1" (change)="save()"> 词卡单词 <input type="radio" [(ngModel)]="word.displayType" [value]="1" (change)="save()" [name]="'displayType_' + i"> 词卡单词
</label> </label>
<label style="font-size: 14px;"> <label style="font-size: 14px;">
<input type="radio" [(ngModel)]="word.displayType" [value]="3" (change)="save()"> 核心单词 <input type="radio" [(ngModel)]="word.displayType" [value]="3" (change)="save()" [name]="'displayType_' + i"> 核心单词
</label> </label>
</div> </div>
</div> </div>
......
...@@ -31,10 +31,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -31,10 +31,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
'art.', 'art.',
'num.', 'num.',
'abbr.', 'abbr.',
'verb phrase', 'phrase',
'noun phrase',
'prep phrase',
'ordinal number', 'ordinal number',
'det.'
]; ];
// 存储courseId // 存储courseId
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment