Commit ad3c9453 authored by wudizhanche1000's avatar wudizhanche1000

添加卸载提示

parent 7e26c85b
...@@ -125,9 +125,13 @@ ...@@ -125,9 +125,13 @@
</div> </div>
<div id="local-files" role="tabpanel" class="tab-pane fade"> <div id="local-files" role="tabpanel" class="tab-pane fade">
<button type="button" (click)="uninstall()"> <div class="list-inline">
<button type="button" [disabled]="!isInstalled" (click)="uninstall()">
{{'uninstall'|translate}} {{'uninstall'|translate}}
</button> </button>
<i *ngIf="uninstalling" class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>
<span class="sr-only">Loading...</span>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -113,9 +113,17 @@ export class AppDetailComponent { ...@@ -113,9 +113,17 @@ export class AppDetailComponent {
} }
uninstalling: boolean;
uninstall(id: string) { uninstall(id: string) {
if (confirm("确认删除?")) {
this.uninstalling = true;
id = this.currentApp.id; id = this.currentApp.id;
this.appsService.uninstall(id); this.appsService.uninstall(id).then(()=> {
this.uninstalling = false;
}
);
}
} }
......
...@@ -229,6 +229,7 @@ export class AppsService { ...@@ -229,6 +229,7 @@ export class AppsService {
deleteFile(path: string): Promise<string> { deleteFile(path: string): Promise<string> {
return new Promise((resolve, reject)=> { return new Promise((resolve, reject)=> {
fs.lstat(path, (err, stats)=> { fs.lstat(path, (err, stats)=> {
if (!err) {
if (stats.isDirectory()) { if (stats.isDirectory()) {
fs.rmdir(path, (err)=> { fs.rmdir(path, (err)=> {
resolve(path); resolve(path);
...@@ -238,6 +239,9 @@ export class AppsService { ...@@ -238,6 +239,9 @@ export class AppsService {
resolve(path); resolve(path);
}); });
} }
} else {
resolve(path);
}
}); });
}) })
} }
...@@ -249,9 +253,9 @@ export class AppsService { ...@@ -249,9 +253,9 @@ export class AppsService {
// 删除本目录 // 删除本目录
files.push('.'); files.push('.');
let install_dir = this.searchApp(id).local.path; let install_dir = this.searchApp(id).local.path;
files return files
.map((file)=> .map((file)=>
()=>Promise.resolve(path.join(install_dir, file)) ()=>path.join(install_dir, file)
) )
.reduce((promise: Promise<string>, task)=> .reduce((promise: Promise<string>, task)=>
promise.then(task).then(this.deleteFile) promise.then(task).then(this.deleteFile)
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
"community": "社区", "community": "社区",
"settings": "设置", "settings": "设置",
"uninstall": "卸载", "uninstall": "卸载",
"general":"常规", "general": "常规",
"updates":"更新", "updates": "更新",
"local files":"本地文件" "local files": "本地文件",
"uninstall confirm": "这将删除所有本地内容,确认执行?"
} }
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