Commit 53d81371 authored by h3remi7's avatar h3remi7

add app-detail

parent f401a953
...@@ -4,6 +4,13 @@ ...@@ -4,6 +4,13 @@
overflow-y: auto; overflow-y: auto;
} }
.hidden {
display: none; .list-group {
width: 20rem;
} }
.news-block {
padding: 0;
}
...@@ -15,49 +15,48 @@ ...@@ -15,49 +15,48 @@
<br> <br>
<h2>新闻</h2> <h2>新闻</h2>
<p>这里是新闻</p>
<br> <p *ngIf="!news">没有新闻</p>
<div *ngIf="news">
<div class="list-group">
<a *ngFor="let item of news" href="{{item.url}}" class="list-group-item">{{item.title}}</a>
</div>
<h2>好友</h2> </div>
<p>好友信息</p>
<br> <br>
<h2>成就</h2> <div *ngIf="friends">
<p>成就信息</p> <h2>好友</h2>
<p>好友信息</p>
<br> <br>
</div>
<h2>Mods</h2> <div *ngIf="achievement">
<h2>成就</h2>
<p>成就信息</p>
<br>
</div>
<table class="table table-striped"> <div *ngIf="mods">
<h2>Mods</h2>
<table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
<th>名称</th> <th>名称</th>
<th>类型</th> <th>类型</th>
<th>启用</th> <th>操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr *ngFor="let mod of mods; let i = index">
<th scope="row">1</th> <th scope="row">{{i + 1}}</th>
<td>东方绯想天</td> <td>{{searchApp(mod.id).name[searchApp(mod.id).locales[0]]}}</td>
<td>依赖</td> <td>{{mod.type}}</td>
<td></td> <td *ngIf="checkInstall(mod.id)"><button type="button" class="btn btn-danger btn-sm">卸载</button></td>
</tr> <td *ngIf="!checkInstall(mod.id)"><button type="button" class="btn btn-primary btn-sm">安装</button></td>
<tr>
<th scope="row">2</th>
<td>简体中文包</td>
<td>语言</td>
<td></td>
</tr>
<tr>
<th scope="row">3</th>
<td>东方绯想天则OST</td>
<td>OST</td>
<td></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
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 'rxjs/Rx';
import {App} from "./app"; import {App} from "./app";
declare var process;
@Component({ @Component({
selector: 'app-detail', selector: 'app-detail',
templateUrl: 'app/app-detail.component.html', templateUrl: 'app/app-detail.component.html',
...@@ -13,14 +14,7 @@ export class AppDetailComponent { ...@@ -13,14 +14,7 @@ export class AppDetailComponent {
_currentApp; _currentApp;
get currentApp(): App { get currentApp(): App {
return this.searchApp(this.routingService.app);
let data = this.appsService.data;
let tmp;
if(data) {
tmp = data.find((v)=>v.id === this.routingService.app);
return tmp;
} else {
}
} }
_name; _name;
...@@ -33,16 +27,80 @@ export class AppDetailComponent { ...@@ -33,16 +27,80 @@ export class AppDetailComponent {
_isInstalled; _isInstalled;
get isInstalled() { get isInstalled() {
return this.checkInstall(this.routingService.app);
}
_news;
get news() {
if(this.currentApp) { if(this.currentApp) {
if(this.currentApp.local.path) { if(this.currentApp.news.length > 0) {
return true; return this.currentApp.news;
}
} }
} }
_friends;
get friends() {
return false; return false;
} }
_achievement;
get achievement() {
return false;
}
_mods;
get mods() {
let contains = ["optional", "language"];
if(this.currentApp) {
if(this.currentApp.references[process.platform] && this.currentApp.references[process.platform].length > 0) {
console.log(this.currentApp.references[process.platform]);
let refs = this.currentApp.references[process.platform];
refs = refs.filter((ref)=>{
return contains.includes(ref.type);
});
refs = refs.map((ref)=>{
let tmp = Object.create(ref);
switch(tmp.type) {
case "optional":
tmp.type = "选项";
break;
case "language":
tmp.type = "语言";
break;
default:
break;
}
console.log(tmp.type);
return tmp;
});
return refs;
//return this.currentApp.references[process.platform];
}
}
}
constructor(private appsService: AppsService, private routingService: RoutingService ) { constructor(private appsService: AppsService, private routingService: RoutingService ) {
} }
searchApp(id): App {
let data = this.appsService.data;
let tmp;
if(data) {
tmp = data.find((v)=>v.id === id);
return tmp;
}
}
checkInstall(id): boolean {
if(this.searchApp(id)) {
if(this.searchApp(id).local.path) {
return true;
}
}
return false;
}
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<a href="#" class="list-group-item list-group-item-action">绯想天</a> <a href="#" class="list-group-item list-group-item-action">绯想天</a>
<a href="#" class="list-group-item list-group-item-action disabled">永远消失的幻想乡</a> <a href="#" class="list-group-item list-group-item-action disabled">永远消失的幻想乡</a>
--> -->
<a *ngFor="let app of appsService.data" <a *ngFor="let app of apps"
(click)="selectApp(app.id)" (click)="selectApp(app.id)"
href="#" href="#"
class="list-group-item list-group-item-action" class="list-group-item list-group-item-action"
......
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',
...@@ -20,6 +21,22 @@ export class AppsComponent { ...@@ -20,6 +21,22 @@ export class AppsComponent {
}); });
} }
_apps;
get apps() {
let contains = ["game", "music", "book"];
let data = this.appsService.data;
let apps;
if(data) {
apps = this.appsService.data.filter((app)=>{
return contains.includes(app.category);
});
}
return apps;
}
selectApp(id) { selectApp(id) {
this.routingService.app = id; this.routingService.app = id;
} }
......
...@@ -8,6 +8,7 @@ import {AppLocal} from "./app-local"; ...@@ -8,6 +8,7 @@ import {AppLocal} from "./app-local";
export class AppsService { export class AppsService {
data : App[]; data : App[];
constructor(private http: Http) { constructor(private http: Http) {
} }
......
...@@ -21,10 +21,7 @@ ...@@ -21,10 +21,7 @@
} }
} }
}, },
"references": { "references": {},
"id": "",
"type": "runtime"
},
"locales": ["zh-CN"], "locales": ["zh-CN"],
"download": "", "download": "",
"news": [{ "news": [{
...@@ -67,9 +64,21 @@ ...@@ -67,9 +64,21 @@
} }
}, },
"references": { "references": {
"darwin": [
{
"id": "th105",
"type": "optional"
},
{
"id": "th12_mod1", "id": "th12_mod1",
"type": "language" "type": "language"
}, },
{
"id": "th12_mod2",
"type": "runtime"
}
]
},
"locales": ["zh-CN"], "locales": ["zh-CN"],
"download": "", "download": "",
"news": [], "news": [],
...@@ -102,10 +111,40 @@ ...@@ -102,10 +111,40 @@
} }
} }
}, },
"references": { "references": {},
"id": "", "locales": ["zh-CN"],
"type": "runtime" "download": "",
"news": [],
"tags": ["STG"],
"local": {
"path": "/foo/bar",
"version": "10.3"
}
},
{
"id": "th12_mod2",
"name":
{
"zh-CN": "th12_mod2"
},
"description": {
"zh-CN": "th12 desc"
},
"author": "ZUN",
"homepage": "http://www.myacg.cc",
"category": "runtime",
"actions": {
"darwin": {
"main": {
"execute": "",
"args": [],
"env": "",
"open": ""
}
}
}, },
"references": {},
"locales": ["zh-CN"], "locales": ["zh-CN"],
"download": "", "download": "",
"news": [], "news": [],
......
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