Commit ebe6ccea authored by 神楽坂玲奈's avatar 神楽坂玲奈

Merge branch 'v3' of github.com:mycard/mycard into v3

parents ffb86554 8d119d4d
......@@ -90,22 +90,28 @@ export class AppDetailComponent implements OnInit {
try {
let downloadApps = await this.downloadService.addUris(apps, downloadPath);
for (let app of apps) {
this.downloadService.getProgress(app)
.subscribe((progress) => {
app.status.status = "downloading";
app.status.progress = progress.progress;
app.status.total = progress.total;
this.ref.detectChanges();
},
(error) => {
},
() => {
// 避免安装过快
if (app.status.status === "downloading") {
app.status.status = "waiting";
await new Promise((resolve, reject) => {
this.downloadService.getProgress(app)
.subscribe((progress) => {
app.status.status = "downloading";
app.status.progress = progress.progress;
app.status.total = progress.total;
this.ref.detectChanges();
}
});
resolve();
},
(error) => {
reject(`download error: ${error}`);
},
() => {
// 避免安装过快
if (app.status.status === "downloading") {
app.status.status = "waiting";
this.ref.detectChanges();
}
});
});
}
await Promise.all(downloadApps.map((app) => {
......
......@@ -59,6 +59,7 @@ export class DownloadService {
} else if (status.status === "active") {
observer.next({total: status.totalLength, progress: status.completedLength})
} else if (status.status === "error") {
console.log("error", status.errorCode);
observer.error(status.errorCode)
}
});
......
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