Commit 750385c9 authored by liujiangnan's avatar liujiangnan

修改文件上传

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