Commit 4fada0a9 authored by wudizhanche1000's avatar wudizhanche1000

更改程序列表

parent 19c6546c
import { Component } from '@angular/core'; import {Component} from '@angular/core';
import { AppsService } from './apps.service' import {AppsService} from './apps.service'
import { RoutingService } from './routing.service' import {RoutingService} from './routing.service'
import {App} from "./app"; import {App} from "./app";
declare var process; declare var process;
...@@ -19,8 +19,9 @@ export class AppDetailComponent { ...@@ -19,8 +19,9 @@ export class AppDetailComponent {
spawn = window['System']._nodeRequire('child_process').spawn; spawn = window['System']._nodeRequire('child_process').spawn;
path = window['System']._nodeRequire('path'); path = window['System']._nodeRequire('path');
constructor(private appsService: AppsService, private routingService: RoutingService ) { constructor(private appsService: AppsService, private routingService: RoutingService) {
} }
_currentApp; _currentApp;
get currentApp(): App { get currentApp(): App {
return this.appsService.searchApp(this.routingService.app); return this.appsService.searchApp(this.routingService.app);
...@@ -28,7 +29,7 @@ export class AppDetailComponent { ...@@ -28,7 +29,7 @@ export class AppDetailComponent {
_name; _name;
get name() { get name() {
if(this.currentApp) { if (this.currentApp) {
return this.currentApp.name[this.currentApp.locales[0]]; return this.currentApp.name[this.currentApp.locales[0]];
} }
return "Loading"; return "Loading";
...@@ -42,8 +43,8 @@ export class AppDetailComponent { ...@@ -42,8 +43,8 @@ export class AppDetailComponent {
_news; _news;
get news() { get news() {
if(this.currentApp) { if (this.currentApp) {
if(this.currentApp.news.length > 0) { if (this.currentApp.news.length > 0) {
return this.currentApp.news; return this.currentApp.news;
} }
} }
...@@ -63,15 +64,15 @@ export class AppDetailComponent { ...@@ -63,15 +64,15 @@ export class AppDetailComponent {
get mods() { get mods() {
let contains = ["optional", "language", "emulator"]; let contains = ["optional", "language", "emulator"];
if(this.currentApp) { if (this.currentApp) {
if(this.currentApp.references[process.platform] && this.currentApp.references[process.platform].length > 0) { if (this.currentApp.references[process.platform] && this.currentApp.references[process.platform].length > 0) {
let refs = this.currentApp.references[process.platform]; let refs = this.currentApp.references[process.platform];
refs = refs.filter((ref)=>{ refs = refs.filter((ref)=> {
return contains.includes(ref.type); return contains.includes(ref.type);
}); });
refs = refs.map((ref)=>{ refs = refs.map((ref)=> {
let tmp = Object.create(ref); let tmp = Object.create(ref);
switch(tmp.type) { switch (tmp.type) {
case "optional": case "optional":
tmp.type = "选项"; tmp.type = "选项";
break; break;
...@@ -92,10 +93,10 @@ export class AppDetailComponent { ...@@ -92,10 +93,10 @@ export class AppDetailComponent {
} }
checkInstall(id): boolean { checkInstall(id): boolean {
if(this.appsService.searchApp(id)) { if (this.appsService.searchApp(id)) {
if(this.appsService.searchApp(id).local.path) { let local = this.appsService.searchApp(id).local;
if (local && local.path) {
return true; return true;
} }
} }
...@@ -105,7 +106,7 @@ export class AppDetailComponent { ...@@ -105,7 +106,7 @@ export class AppDetailComponent {
install(id) { install(id) {
let uri = this.appsService.searchApp(id).download[process.platform]; let uri = this.appsService.searchApp(id).download[process.platform];
console.log(process.platform); console.log(process.platform);
if(uri) { if (uri) {
this.appsService.download(id, uri); this.appsService.download(id, uri);
} else { } else {
console.log("lost download uri!"); console.log("lost download uri!");
...@@ -117,8 +118,8 @@ export class AppDetailComponent { ...@@ -117,8 +118,8 @@ export class AppDetailComponent {
installSubmit(theForm) { installSubmit(theForm) {
console.log(theForm); console.log(theForm);
this.install(this.routingService.app); this.install(this.routingService.app);
for(let mod in this.appsService.installConfig.mods) { for (let mod in this.appsService.installConfig.mods) {
if(this.appsService.installConfig.mods[mod]) { if (this.appsService.installConfig.mods[mod]) {
this.install(mod); this.install(mod);
} }
} }
...@@ -132,6 +133,7 @@ export class AppDetailComponent { ...@@ -132,6 +133,7 @@ export class AppDetailComponent {
this.appsService.installConfig.installDir = dir[0]; this.appsService.installConfig.installDir = dir[0];
return dir[0]; return dir[0];
} }
openDir(id) { openDir(id) {
this.electron.remote.shell.showItemInFolder(this.appsService.searchApp(id).local.path); this.electron.remote.shell.showItemInFolder(this.appsService.searchApp(id).local.path);
} }
...@@ -147,9 +149,9 @@ export class AppDetailComponent { ...@@ -147,9 +149,9 @@ export class AppDetailComponent {
let open = ''; let open = '';
let openId = this.appsService.searchApp(id).actions[process.platform]["main"].open; let openId = this.appsService.searchApp(id).actions[process.platform]["main"].open;
if(openId) { if (openId) {
this.appsService.searchApp(openId).actions[process.platform]["main"].execute; this.appsService.searchApp(openId).actions[process.platform]["main"].execute;
if(this.checkInstall(openId)) { if (this.checkInstall(openId)) {
open = this.path.join(this.appsService.searchApp(openId).local.path, this.appsService.searchApp(openId).actions[process.platform]["main"].execute); open = this.path.join(this.appsService.searchApp(openId).local.path, this.appsService.searchApp(openId).actions[process.platform]["main"].execute);
args.push(execute); args.push(execute);
} else { } else {
...@@ -180,5 +182,4 @@ export class AppDetailComponent { ...@@ -180,5 +182,4 @@ export class AppDetailComponent {
} }
} }
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { AppsService } from './apps.service' import { AppsService } from './apps.service'
import { RoutingService } from './routing.service' import { RoutingService } from './routing.service'
import {App} from "./app";
@Component({ @Component({
selector: 'apps', selector: 'apps',
......
This diff is collapsed.
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