Commit 078de2f6 authored by wudizhanche1000's avatar wudizhanche1000

类名Merge

parent 8ad7dc2b
<h1>{{currentApp.name}}</h1> <h1>{{currentApp.name}}</h1>
<div *ngIf="currentApp.status.status === 'init'"> <!--应用未安装-->
<button i18n type="button" class="btn btn-primary" data-toggle="modal" (click)="updateInstallOption(currentApp)" data-target="#install-modal">安装</button> <div class="actions" *ngIf="!currentApp.isInstalled()">
<button i18n type="button" class="btn btn-primary" data-toggle="modal" (click)="updateInstallOption(currentApp)" data-target="#install-modal">
安装
</button>
<button i18n type="button" class="btn btn-secondary">导入</button> <button i18n type="button" class="btn btn-secondary">导入</button>
</div> </div>
<div i18n *ngIf="currentApp.status.status === 'installing'">正在安装...</div>
<div i18n *ngIf="currentApp.status.status==='waiting'">等待安装...</div> <!--应用变更中-->
<progress *ngIf="currentApp.status.status === 'downloading'||currentApp.status.status==='installing'" class="progress progress-striped progress-animated" value="{{currentApp.status.progress}}" max="{{currentApp.status.total}}"></progress> <div class="actions" *ngIf="currentApp.isInstalled() && !currentApp.isReady()">
<div class="actions" *ngIf="currentApp.status.status==='ready' && (currentApp.id != 'ygopro')"> <div *ngIf="currentApp.isDownloading()">
<button i18n *ngIf="currentApp.runable()" (click)="runApp(currentApp)" type="button" class="btn btn-primary">运行</button> <span>正在下载</span><span *ngIf="currentApp.status.total">{{currentApp.status.progress/currentApp.status.total}}%</span>
<button i18n *ngIf="currentApp.runable() && currentApp.actions.get('custom')" (click)="custom(currentApp)" type="button" class="btn btn-secondary">设置</button> </div>
<div i18n *ngIf="currentApp.isInstalling()">正在安装...</div>
<div i18n *ngIf="currentApp.isWaiting()">等待安装...</div>
<progress class="progress" [class.progress-striped]="!currentApp.status.total" [class.progress-animated]="!currentApp.status.total" value="{{currentApp.status.progress}}" max="{{currentApp.status.total}}"></progress>
</div>
<!--应用ready-->
<div class="actions" *ngIf="currentApp.isReady() && (currentApp.id != 'ygopro')">
<button i18n *ngIf="currentApp.runable()" (click)="runApp(currentApp)" type="button" class="btn btn-primary">运行
</button>
<button i18n *ngIf="currentApp.runable() && currentApp.actions.get('custom')" (click)="custom(currentApp)" type="button" class="btn btn-secondary">
设置
</button>
<div id="network" *ngIf="currentApp.network && currentApp.network.protocol == 'maotama'"> <div id="network" *ngIf="currentApp.network && currentApp.network.protocol == 'maotama'">
<div class="input-group"> <div class="input-group">
<input *ngIf="appsService.connections.get(currentApp)" [value]="appsService.connections.get(currentApp).address || 'Loading...'" readonly type="text" class="form-control" title="address"> <input *ngIf="appsService.connections.get(currentApp)" [value]="appsService.connections.get(currentApp).address || 'Loading...'" readonly type="text" class="form-control" title="address">
<div class="input-group-btn"> <div class="input-group-btn">
<button i18n *ngIf="!appsService.connections.get(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-secondary">联机</button> <button i18n *ngIf="!appsService.connections.get(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-secondary">
<button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-secondary">复制</button> 联机
</button>
<button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-secondary">
复制
</button>
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" style="height: 38px;"></button> <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" style="height: 38px;"></button>
<div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)"> <div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)">
<h6 i18n class="dropdown-header">选择服务器</h6> <h6 i18n class="dropdown-header">选择服务器</h6>
...@@ -24,16 +43,16 @@ ...@@ -24,16 +43,16 @@
</div> </div>
</div> </div>
</div> </div>
<ygopro *ngIf="currentApp.status.status==='ready'&& (currentApp.id == 'ygopro')" [app]="currentApp"></ygopro> <ygopro *ngIf="currentApp.isReady() && (currentApp.id == 'ygopro')" [app]="currentApp"></ygopro>
<h2 i18n *ngIf="news && news.length">新闻</h2> <h2 i18n *ngIf="news && news.length">新闻</h2>
<div id="news" *ngFor="let item of news"> <div id="news" *ngFor="let item of news">
<h3>{{item.title}}</h3> <h3>{{item.title}}</h3>
<p>{{item.text}}</p> <p>{{item.text}}</p>
<a i18n *ngIf="item.url" [href]="item.url">了解更多</a> <a i18n *ngIf="item.url" [href]="item.url" target="_blank">了解更多</a>
</div> </div>
<div *ngIf="currentApp.isInstalled()"> <div *ngIf="currentApp.isInstalled()">
<div *ngIf="mods && mods.length"> <div *ngIf="mods && mods.length">
<h2>扩展内容</h2>
<table class="table table-striped"> <table class="table table-striped">
<thead class="thead-inverse"> <thead class="thead-inverse">
<tr> <tr>
...@@ -50,7 +69,9 @@ ...@@ -50,7 +69,9 @@
<button i18n type="button" (click)="uninstall(mod)" class="btn btn-danger btn-sm">卸载</button> <button i18n type="button" (click)="uninstall(mod)" class="btn btn-danger btn-sm">卸载</button>
</td> </td>
<td *ngIf="!mod.isInstalled()"> <td *ngIf="!mod.isInstalled()">
<button i18n (click)="installMod(mod)" type="button" *ngIf="mod.status.status==='init'" class="btn btn-primary btn-sm">安装</button> <button i18n (click)="installMod(mod)" type="button" *ngIf="mod.status.status==='init'" class="btn btn-primary btn-sm">
安装
</button>
<progress *ngIf="mod.status.status==='downloading'" class="progress progress-striped progress-animated" value="{{mod.status.progress}}" max="{{mod.status.total}}"></progress> <progress *ngIf="mod.status.status==='downloading'" class="progress progress-striped progress-animated" value="{{mod.status.progress}}" max="{{mod.status.total}}"></progress>
<div i18n *ngIf="mod.status.status==='waiting'">等待安装...</div> <div i18n *ngIf="mod.status.status==='waiting'">等待安装...</div>
</td> </td>
...@@ -63,6 +84,8 @@ ...@@ -63,6 +84,8 @@
<button i18n type="button" class="btn btn-secondary">校验完整性</button> <button i18n type="button" class="btn btn-secondary">校验完整性</button>
<button i18n (click)="uninstall(currentApp)" type="button" class="btn btn-secondary">卸载</button> <button i18n (click)="uninstall(currentApp)" type="button" class="btn btn-secondary">卸载</button>
</div> </div>
<!--安装modal-->
<div class="modal fade" id="install-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" *ngIf="installOption"> <div class="modal fade" id="install-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" *ngIf="installOption">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<form id="install-form" class="modal-content" (ngSubmit)="install(currentApp)" #theForm="ngForm"> <form id="install-form" class="modal-content" (ngSubmit)="install(currentApp)" #theForm="ngForm">
...@@ -81,17 +104,17 @@ ...@@ -81,17 +104,17 @@
</select></div> </select></div>
<h4 i18n>快捷方式</h4> <h4 i18n>快捷方式</h4>
<div class="checkbox"> <div class="checkbox">
<input id="create_application_shortcut" type="checkbox" name="application" [(ngModel)]="installOption.createShortcut">
<label i18n *ngIf="platform == 'darwin'" for="create_application_shortcut">创建 LaunchPad 快捷方式</label> <label i18n *ngIf="platform == 'darwin'" for="create_application_shortcut">创建 LaunchPad 快捷方式</label>
<label i18n *ngIf="platform == 'win32'" for="create_application_shortcut">创建开始菜单快捷方式</label> <label i18n *ngIf="platform == 'win32'" for="create_application_shortcut">创建开始菜单快捷方式</label>
<input id="create_application_shortcut" type="checkbox" name="application" [(ngModel)]="installOption.createShortcut">
</div> </div>
<div class="checkbox"> <div class="checkbox">
<label i18n for="create_desktop_shortcut">创建桌面快捷方式</label>
<input id="create_desktop_shortcut" type="checkbox" name="desktop" [(ngModel)]="installOption.createDesktopShortcut"> <input id="create_desktop_shortcut" type="checkbox" name="desktop" [(ngModel)]="installOption.createDesktopShortcut">
<label i18n for="create_desktop_shortcut">创建桌面快捷方式</label>
</div> </div>
<!--<h4 *ngIf="installOption.references.length">扩展内容</h4>--> <!--<h4 *ngIf="installOption.references.length">扩展内容</h4>-->
<!--<div *ngFor="let reference of installOption.references"><label>--> <!--<div *ngFor="let reference of installOption.references"><label>-->
<!--<input type="checkbox" [(ngModel)]="reference.install" name="references" value="{{reference.app.id}}"> {{reference.app.name}}--> <!--<input type="checkbox" [(ngModel)]="reference.install" name="references" value="{{reference.app.id}}"> {{reference.app.name}}-->
<!--</label></div>--> <!--</label></div>-->
<div *ngIf="currentApp.findDependencies().length"> <div *ngIf="currentApp.findDependencies().length">
<span i18n>依赖:</span> <span i18n>依赖:</span>
......
...@@ -41,7 +41,11 @@ export class InstallService { ...@@ -41,7 +41,11 @@ export class InstallService {
constructor(private http: Http, private ref: ApplicationRef) { constructor(private http: Http, private ref: ApplicationRef) {
if (process.platform === "win32") { if (process.platform === "win32") {
this.tarPath = path.join(process.resourcesPath, 'bin', 'bsdtar.exe'); if (process.env['NODE_ENV'] == 'production') {
this.tarPath = path.join(process.resourcesPath, 'bin', 'bsdtar.exe');
} else {
this.tarPath = path.join('bin', 'bsdtar.exe');
}
} else { } else {
this.tarPath = "bsdtar" this.tarPath = "bsdtar"
} }
...@@ -81,54 +85,55 @@ export class InstallService { ...@@ -81,54 +85,55 @@ export class InstallService {
try { try {
let app = task.app; let app = task.app;
let option = task.option; let option = task.option;
if (!app.isInstalled()) { // if (!app.isInstalled()) {
let checksumFile = await this.getChecksumFile(app); let checksumFile = await this.getChecksumFile(app);
if (app.parent) { console.log(checksumFile);
let conflictFiles = new Set<string>(); if (app.parent) {
let parentFilesMap = app.parent.local!.files; let conflictFiles = new Set<string>();
for (let key of checksumFile.keys()) { let parentFilesMap = app.parent.local!.files;
if (parentFilesMap.has(key)) { for (let key of checksumFile.keys()) {
conflictFiles.add(key); if (parentFilesMap.has(key)) {
} conflictFiles.add(key);
}
if (conflictFiles.size > 0) {
let backupPath = path.join(option.installLibrary, "backup", app.parent.id);
this.backupFiles(option.installDir, backupPath, conflictFiles);
} }
} }
let allFiles = new Set(checksumFile.keys()); if (conflictFiles.size > 0) {
app.status.status = "installing"; let backupPath = path.join(option.installLibrary, "backup", app.parent.id);
app.status.total = allFiles.size; this.backupFiles(option.installDir, backupPath, conflictFiles);
app.status.progress = 0;
let timeNow = new Date().getTime();
for (let file of option.downloadFiles) {
await this.createDirectory(option.installDir);
await new Promise((resolve, reject) => {
this.extract(file, option.installDir).subscribe(
(lastItem: string) => {
console.log(app.status.progress, app.status.total, lastItem);
app.status.progress += 1;
if (new Date().getTime() - timeNow > 500) {
timeNow = new Date().getTime();
this.ref.tick();
}
},
(error) => {
reject(error);
},
() => {
resolve();
});
});
} }
let local = new AppLocal();
local.path = option.installDir;
local.files = checksumFile;
local.version = app.version;
app.local = local;
this.saveAppLocal(app);
app.status.status = "ready";
} }
let allFiles = new Set(checksumFile.keys());
app.status.status = "installing";
app.status.total = allFiles.size;
app.status.progress = 0;
let timeNow = new Date().getTime();
for (let file of option.downloadFiles) {
await this.createDirectory(option.installDir);
await new Promise((resolve, reject) => {
this.extract(file, option.installDir).subscribe(
(lastItem: string) => {
console.log(app.status.progress, app.status.total, lastItem);
app.status.progress += 1;
if (new Date().getTime() - timeNow > 500) {
timeNow = new Date().getTime();
this.ref.tick();
}
},
(error) => {
reject(error);
},
() => {
resolve();
});
});
}
let local = new AppLocal();
local.path = option.installDir;
local.files = checksumFile;
local.version = app.version;
app.local = local;
this.saveAppLocal(app);
app.status.status = "ready";
// }
} catch (e) { } catch (e) {
throw e; throw e;
} }
......
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