加载进度事件

This commit is contained in:
AncTe committed 2023-06-17 17:25:55 +08:00
1 parent 754edac71a
commit 6eacff68d3
4 files changed
+45 -34

No files matched your search

+12 -2
View File
@@ -147,7 +147,12 @@ export class Resource<
) {
this.emit('loadstart');
this.request = axios
.get(data, { responseType: this.format })
.get(data, {
responseType: this.format,
onDownloadProgress: e => {
this.emit('progress', e);
}
})
.then(v => {
this.resource = v.data;
this.loaded = true;
@@ -157,7 +162,12 @@ export class Resource<
} else if (this.format === 'zip') {
this.emit('loadstart');
this.request = axios
.get(data, { responseType: 'arraybuffer' })
.get(data, {
responseType: 'arraybuffer',
onDownloadProgress: e => {
this.emit('progress', e);
}
})
.then(v => {
this.resource = new ZippedResource(v.data);
this.loaded = true;