Commit 750385c9 authored by liujiangnan's avatar liujiangnan

修改文件上传

parent 9bbf94dd
......@@ -3,6 +3,7 @@
"version": "0.0.1",
"scripts": {
"start": "ng serve",
"build": "ng build --build--optimizer --aot --base-href /JGT/v3/",
"publish": "node ./bin/publish.js"
},
"private": true,
......
......@@ -11,11 +11,10 @@
</div>
<nz-upload
[nzAccept] = "'.mp3'"
[nzShowUploadList]="false"
[nzBeforeUpload]="beforeUpload">
<!-- nzAction="/user/resource" -->
<!--(nzChange)="handleChange($event)"-->
[nzShowUploadList]="false"
[nzAction]="uploadUrl"
[nzData]="uploadData"
(nzChange)="handleChange($event)">
<div class="btn-upload" [ngClass]="{'has-clear': withRmBtn && (audioUrl || audioBlob)}" *ngIf="type===Type.UPLOAD && !isUploading">
<fa name="upload"></fa>
......
......@@ -21,6 +21,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
Type = Type;
withRmBtn = false;
uploadUrl = (<any>window).courseware.uploadUrl();
uploadData = (<any>window).courseware.uploadData();
@Input()
needRemove = false;
......@@ -70,6 +73,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
// this.beforeUpload(this.audioItem);
}
ngOnInit() {
this.audio.onplay = () => {
this.onPlay();
};
......@@ -148,7 +152,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
this.audioRemoved.emit();
}
handleChange(info: { type: string, file: UploadFile, event: any }): void {
handleChange(info: { type: string, file: UploadFile, event: any }): void {
switch (info.type) {
case 'start':
this.isUploading = true;
......@@ -156,6 +160,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
break;
case 'success':
this.isUploading = false;
this.uploadSuccess(info.file.response);
this.audioUploaded.emit(info.file.response);
break;
case 'progress':
......@@ -184,20 +189,12 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
this.audioUrl = null;
if (!this.checkSelectFile(file)) {
return;
return false;
}
this.isUploading = true;
this.progress = 0;
let path = '/imman/audios/';
if (!environment.production) {
path = '/dev' + path;
}
window['net'].doUpload(file as any, 1, path,
this.doProgress , this.uploadSuccess , this.uploadFailure );
return false;
this.progress = 0;
}
uploadSuccess = (id, name, hash, url, file?: File, inOss = false) => {
uploadSuccess = (url) => {
this.nzMessageService.info('Upload Success');
this.isUploading = false;
this.audioUrl = url;
......
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