Commit 6a4f6518 authored by wudizhanche1000's avatar wudizhanche1000

安装完成更新界面

parent 32be85f0
...@@ -136,9 +136,11 @@ export class AppDetailComponent implements OnInit { ...@@ -136,9 +136,11 @@ export class AppDetailComponent implements OnInit {
(error)=> { (error)=> {
}, },
()=> { ()=> {
// 避免安装过快
if (currentApp.status.status === "downloading") {
currentApp.status.status = "waiting"; currentApp.status.status = "waiting";
this.ref.detectChanges(); this.ref.detectChanges();
}
}); });
await Promise.all(downloadApps.map((app)=> { await Promise.all(downloadApps.map((app)=> {
return this.downloadService.getComplete(app) return this.downloadService.getComplete(app)
...@@ -146,7 +148,11 @@ export class AppDetailComponent implements OnInit { ...@@ -146,7 +148,11 @@ export class AppDetailComponent implements OnInit {
return this.installService.add(completeApp, options); return this.installService.add(completeApp, options);
}); });
})); }));
console.log("before")
await this.installService.getComplete(currentApp);
console.log("install complete");
currentApp.status.status = "ready"; currentApp.status.status = "ready";
this.ref.detectChanges();
} catch (e) { } catch (e) {
new Notification(currentApp.name, {body: "下载失败"}); new Notification(currentApp.name, {body: "下载失败"});
} }
......
import {App} from "./app";
/** /**
* Created by zh99998 on 16/9/6. * Created by zh99998 on 16/9/6.
*/ */
...@@ -5,6 +6,7 @@ export class AppLocal { ...@@ -5,6 +6,7 @@ export class AppLocal {
path: string; path: string;
version: string; version: string;
files: Map<string,string>; files: Map<string,string>;
action: Map<string,{execute: string, args: string[], env: {}, open: App}>;
update(local) { update(local) {
this.path = local.path; this.path = local.path;
......
This diff is collapsed.
...@@ -41,7 +41,12 @@ export class InstallService { ...@@ -41,7 +41,12 @@ export class InstallService {
} }
getComplete(app: App): Promise<App> { getComplete(app: App): Promise<App> {
return null; return new Promise((resolve, reject)=> {
this.eventEmitter.once(app.id, (complete)=> {
console.log("receive ",app.id);
resolve();
});
});
} }
extract(file: string, destPath: string) { extract(file: string, destPath: string) {
...@@ -151,7 +156,6 @@ export class InstallService { ...@@ -151,7 +156,6 @@ export class InstallService {
destPath = path.join(options.installLibrary, app.id); destPath = path.join(options.installLibrary, app.id);
await this.createDirectory(destPath); await this.createDirectory(destPath);
} }
this.installQueue.delete(app);
await this.extract(packagePath, destPath); await this.extract(packagePath, destPath);
await this.postInstall(app, destPath); await this.postInstall(app, destPath);
let local = new AppLocal(); let local = new AppLocal();
...@@ -160,6 +164,9 @@ export class InstallService { ...@@ -160,6 +164,9 @@ export class InstallService {
local.version = app.version; local.version = app.version;
app.local = local; app.local = local;
this.saveAppLocal(app); this.saveAppLocal(app);
console.log("send ",app.id);
this.eventEmitter.emit(app.id, 'install complete');
this.installQueue.delete(app);
this.installingQueue.delete(app); this.installingQueue.delete(app);
if (this.installQueue.size > 0) { if (this.installQueue.size > 0) {
await this.doInstall() await this.doInstall()
......
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