Commit 6a532662 authored by 神楽坂玲奈's avatar 神楽坂玲奈

login

parents 47770a6b de8359d8
<h1>{{'app.' + currentApp.id + '.name' | translate}}</h1>
<h1>{{'app.' + appsService.currentApp.id + '.name' | translate}}</h1>
<h2>{{appsService._aa}}</h2>
<div *ngIf="!isInstalled">
<div *ngIf="!appsService.getDownloadInfo(routingService.app)">
<button type="button" (click)="updateInstallConfig()" class="btn btn-primary" data-toggle="modal" data-target="#install-modal">安装</button>
<div *ngIf="!appsService.getDownloadInfo(appsService.currentApp)">
<button type="button" (click)="updateInstallConfig()" class="btn btn-primary" data-toggle="modal"
data-target="#install-modal">安装
</button>
<button type="button" class="btn btn-secondary">导入</button>
<!--<button type="button" class="btn btn-secondary">正版代购</button>-->
</div>
<div *ngIf="appsService.getDownloadInfo(routingService.app)">
<div *ngIf="appsService.getDownloadInfo(routingService.app).status === 'install'">正在安装...</div>
<div *ngIf="appsService.getDownloadInfo(routingService.app).status === 'wait'">等待安装...</div>
<progress *ngIf="appsService.getDownloadInfo(routingService.app).status === 'active'"
<div *ngIf="appsService.getDownloadInfo(appsService.currentApp)">
<div *ngIf="appsService.getDownloadInfo(appsService.currentApp).status === 'install'">正在安装...</div>
<div *ngIf="appsService.getDownloadInfo(appsService.currentApp).status === 'wait'">等待安装...</div>
<progress *ngIf="appsService.getDownloadInfo(appsService.currentApp).status === 'active'"
class="progress progress-striped progress-animated"
value="{{appsService.getDownloadInfo(routingService.app).progress}}" max="100">
value="{{appsService.getDownloadInfo(appsService.currentApp).progress}}" max="100">
</progress>
</div>
</div>
<div *ngIf="isInstalled && (routingService.app != 'ygopro')">
<button (click)="startApp(routingService.app)" type="button" class="btn btn-primary">运行</button>
<div *ngIf="isInstalled && (appsService.currentApp != 'ygopro')">
<button (click)="startApp(appsService.currentApp)" type="button" class="btn btn-primary">运行</button>
<button type="button" data-toggle="modal" data-target="#settings-modal" class="btn btn-secondary">设置</button>
<!--<button (click)="appsService.browse(routingService.app)" type="button" class="btn btn-secondary">游览本地文件</button>-->
<!--<button (click)="appsService.browse(appsService.currentApp)" type="button" class="btn btn-secondary">游览本地文件</button>-->
<button type="button" class="btn btn-secondary">联机</button>
</div>
<ygopro *ngIf="isInstalled && (routingService.app == 'ygopro')"></ygopro>
<ygopro *ngIf="isInstalled && (appsService.currentApp == 'ygopro')"></ygopro>
<br>
<h2 *ngIf="news">新闻</h2>
<!--<div *ngIf="news">
<div class="list-group">
<a *ngFor="let item of news" href="{{item.url}}" class="list-group-item">{{item.title}}</a>
</div>
</div>-->
<!--<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li *ngFor="let item of news; let index = index;" data-target="#carousel-example-generic" [data-slide-to]="index" [class.active]="index == 0"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div *ngFor="let item of news; let index = index;" class="carousel-item" [class.active]="index == 0">
<img [src]="item.image" [alt]="item.title">
<div class="carousel-caption">
<h3>{{item.title}}</h3>
<p>{{item.text}}</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="icon-prev" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="icon-next" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>-->
<div id="news" *ngFor="let item of news">
<h3>{{item.title}}</h3>
<p>{{item.text}}</p>
......@@ -116,7 +88,7 @@
<div *ngIf="isInstalled">
<h2>本地文件</h2>
<button (click)="appsService.browse(routingService.app)" type="button" class="btn btn-secondary">浏览本地文件</button>
<button (click)="appsService.browse(appsService.currentApp)" type="button" class="btn btn-secondary">浏览本地文件</button>
<button (click)="uninstall()" type="button" class="btn btn-secondary">{{'uninstall'|translate}}</button>
</div>
......@@ -189,7 +161,7 @@
<h4>{{'install_path'|translate}}</h4>
<div class="form-group">
<select class="form-control">
<option *ngFor="let library of settings.getLibraries()" [selected]="library['default']">
<option *ngFor="let library of settingsService.getLibraries()" [selected]="library['default']">
{{ library['path']}}
</option>
</select>
......
import {Component, OnInit} from "@angular/core";
import {AppsService} from "./apps.service";
import {RoutingService} from "./routing.service";
import {App} from "./app";
import {InstallConfig} from "./install-config";
import {SettingsService} from "./settings.sevices";
......@@ -13,7 +11,7 @@ declare var $;
templateUrl: 'app/app-detail.component.html',
styleUrls: ['app/app-detail.component.css'],
})
export class AppDetailComponent implements OnInit{
export class AppDetailComponent implements OnInit {
platform = process.platform;
fs = window['System']._nodeRequire('fs');
......@@ -23,37 +21,34 @@ export class AppDetailComponent implements OnInit{
installConfig: InstallConfig;
ngOnInit(){
this.updateInstallConfig();
}
updateInstallConfig() {
this.installConfig = this.appsService.getInstallConfig(this.currentApp);
constructor(private appsService: AppsService, private settingsService: SettingsService) {
}
constructor(private appsService: AppsService, private routingService: RoutingService, private settings: SettingsService) {
ngOnInit() {
this.updateInstallConfig();
}
get currentApp(): App {
return this.appsService.searchApp(this.routingService.app);
updateInstallConfig() {
this.installConfig = this.appsService.getInstallConfig(this.appsService.currentApp);
}
get name() {
if (this.currentApp) {
return this.currentApp.name[this.currentApp.locales[0]];
let currentApp = this.appsService.currentApp;
if (currentApp) {
return currentApp.name[this.settingsService.getLocale()];
}
return "Loading";
};
get isInstalled() {
return this.checkInstall(this.routingService.app);
return this.checkInstall(this.appsService.currentApp);
}
get news() {
if (this.currentApp) {
if (this.currentApp.news.length > 0) {
return this.currentApp.news;
}
let currentApp = this.appsService.currentApp;
if (currentApp) {
return currentApp.news;
}
}
......@@ -68,9 +63,10 @@ export class AppDetailComponent implements OnInit{
get mods() {
let contains = ["optional", "language", "emulator"];
if (this.currentApp) {
if (this.currentApp.references[process.platform] && this.currentApp.references[process.platform].length > 0) {
let refs = this.currentApp.references[process.platform];
let currentApp = this.appsService.currentApp;
if (currentApp) {
if (currentApp.references[process.platform] && currentApp.references[process.platform].length > 0) {
let refs = currentApp.references[process.platform];
refs = refs.filter((ref)=> {
return contains.includes(ref.type);
});
......@@ -123,7 +119,6 @@ export class AppDetailComponent implements OnInit{
uninstall(id: string) {
if (confirm("确认删除?")) {
this.uninstalling = true;
id = this.currentApp.id;
this.appsService.uninstall(id).then(()=> {
this.uninstalling = false;
}
......
<span *ngIf="grouped_apps.installed">已安装</span>
<ul *ngIf="grouped_apps.installed" class="nav nav-sidebar">
<li *ngFor="let app of grouped_apps.installed" [class.active]="app.id==routingService.app">
<a (click)="selectApp(app.id)" href="#">{{app.name[app.locales[0]]}}</a>
<li *ngFor="let app of grouped_apps.installed" [class.active]="app===appsService.currentApp">
<a (click)="chooseApp(app)" href="#">{{app.name[app.locales[0]]}}</a>
</li>
</ul>
<span *ngIf="grouped_apps.yugioh">游戏王</span>
<ul *ngIf="grouped_apps.yugioh" class="nav nav-sidebar">
<li *ngFor="let app of grouped_apps.yugioh" [class.active]="app.id==routingService.app">
<a (click)="selectApp(app.id)" href="#">{{app.name[app.locales[0]]}}</a>
<li *ngFor="let app of grouped_apps.yugioh" [class.active]="app===appsService.currentApp">
<a (click)="chooseApp(app)" href="#">{{app.name[app.locales[0]]}}</a>
</li>
</ul>
<span *ngIf="grouped_apps.touhou">东方 Project</span>
<ul *ngIf="grouped_apps.touhou" class="nav nav-sidebar">
<li *ngFor="let app of grouped_apps.touhou" [class.active]="app.id==routingService.app">
<a (click)="selectApp(app.id)" href="#">{{app.name[app.locales[0]]}}</a>
<li *ngFor="let app of grouped_apps.touhou" [class.active]="app===appsService.currentApp">
<a (click)="chooseApp(app)" href="#">{{app.name[app.locales[0]]}}</a>
</li>
</ul>
<span *ngIf="grouped_apps.touhou_pc98">东方旧作</span>
<ul *ngIf="grouped_apps.touhou_pc98" class="nav nav-sidebar">
<li *ngFor="let app of grouped_apps.touhou_pc98" [class.active]="app.id==routingService.app">
<a (click)="selectApp(app.id)" href="#">{{app.name[app.locales[0]]}}</a>
<li *ngFor="let app of grouped_apps.touhou_pc98" [class.active]="app===appsService.currentApp">
<a (click)="chooseApp(app)" href="#">{{app.name[app.locales[0]]}}</a>
</li>
</ul>
\ No newline at end of file
import {Component, OnInit} from "@angular/core";
import {AppsService} from "./apps.service";
import {RoutingService} from "./routing.service";
import {App} from "./app";
@Component({
selector: 'apps',
......@@ -9,31 +9,16 @@ import {RoutingService} from "./routing.service";
})
export class AppsComponent implements OnInit {
constructor(private appsService: AppsService, private routingService: RoutingService) {
constructor(private appsService: AppsService) {
}
ngOnInit() {
}
// _apps;
// get apps() {
//
// let data = this.appsService.data;
// let apps;
//
// if (data) {
// apps = this.appsService.data.filter((app)=> {
// return contains.includes(app.category);
// });
// }
//
// return apps || [];
// }
//
// selectApp(id) {
// this.routingService.app = id;
// this.appsService.createInstallConfig(id);
// }
chooseApp(app: App) {
this.appsService.currentApp = app;
}
get grouped_apps() {
let contains = ["game", "music", "book"];
......
......@@ -19,7 +19,15 @@ const execFile = window['System']._nodeRequire('child_process').execFile;
export class AppsService {
currentApp: App;
private _currentApp: App;
get currentApp(): App {
return this._currentApp;
}
set currentApp(app: App) {
this._currentApp = app;
}
constructor(private http: Http, private translate: TranslateService, private settings: SettingsService) {
let loop = setInterval(()=> {
......@@ -197,23 +205,6 @@ export class AppsService {
.subscribe((apps) => {
console.log(apps);
this.data = apps;
// for (let app of data) {
// }
// this.data = data;
// for (let app of data) {
// //console.log(app)
// for (let attribute of ['name', 'description']) {
// if (!app[attribute]) {
// continue
// } //这句应当是不需要的, 如果转换成了 App 类型, 应当保证一定有这些属性
// for (let locale of Object.keys(app[attribute])) {
// let result = {};
// result[`app.${app['id']}.${attribute}`] = app[attribute][locale];
// this.translate.setTranslation(locale, result, true);
// }
// }
// }
//console.log(this.data);
if (typeof(callback) === 'function') {
callback();
}
......
import { Component } from '@angular/core';
import {RoutingService} from "./routing.service";
@Component({
selector: '#candy',
templateUrl: 'app/candy.component.html',
styleUrls: ['app/candy.component.css'],
})
export class CandyComponent {
constructor(private routingService: RoutingService){
constructor(){
}
}
<!-- Begin page content -->
<div id="main">
<apps *ngIf="appsService.allApps"></apps>
<app-detail *ngIf="routingService.app"></app-detail>
<app-detail *ngIf="appsService._currentApp"></app-detail>
<roster></roster>
</div>
<webview id="candy"
......
......@@ -2,7 +2,6 @@
* Created by zh99998 on 16/9/2.
*/
import {Component} from "@angular/core";
import {RoutingService} from "./routing.service";
import {AppsService} from "./apps.service";
@Component({
selector: 'lobby',
......@@ -10,6 +9,6 @@ import {AppsService} from "./apps.service";
styleUrls: ['app/lobby.component.css'],
})
export class LobbyComponent {
constructor(private routingService: RoutingService, private appsService: AppsService) {
constructor(private appsService: AppsService) {
}
}
import {Component, Renderer} from "@angular/core";
import {TranslateService} from "ng2-translate";
import {RoutingService} from "./routing.service";
import {LoginService} from "./login.service";
const electron = System._nodeRequire('electron');
declare var process;
......@@ -19,8 +18,7 @@ export class MyCardComponent {
platform = process.platform;
constructor(private routingService: RoutingService, private renderer: Renderer, private translate: TranslateService, private loginService: LoginService) {
constructor(private renderer: Renderer, private translate: TranslateService, private loginService: LoginService) {
renderer.listenGlobal('window', 'message', (event) => {
console.log(event);
// Do something with 'event'
......
......@@ -12,7 +12,6 @@ import {RosterComponent} from "./roster.component";
import {CandyComponent} from "./candy.component";
import {CommunityComponent} from "./community.component";
import {YGOProComponent} from "./ygopro.component";
import {RoutingService} from "./routing.service";
import {AppsService} from "./apps.service";
import {TranslateModule} from "ng2-translate";
import {SettingsService} from "./settings.sevices";
......@@ -22,7 +21,7 @@ import {LoginService} from "./login.service";
imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule, TranslateModule.forRoot()],
declarations: [MyCardComponent, LoginComponent, StoreComponent, LobbyComponent, CommunityComponent, AppsComponent, AppDetailComponent, RosterComponent, CandyComponent, YGOProComponent],
bootstrap: [MyCardComponent],
providers: [RoutingService, AppsService, SettingsService, LoginService],
providers: [AppsService, SettingsService, LoginService],
schemas: [NO_ERRORS_SCHEMA]
})
export class MyCard {
......
import { Injectable } from '@angular/core';
@Injectable()
export class RoutingService {
component = 'lobby';
app;
}
\ No newline at end of file
/**
* Created by zh99998 on 16/9/2.
*/
import {Component, OnInit, ChangeDetectorRef} from '@angular/core';
import {Component, OnInit, ChangeDetectorRef} from "@angular/core";
import {AppsService} from "./apps.service";
import {RoutingService} from "./routing.service";
declare var process;
......@@ -56,7 +55,7 @@ export class YGOProComponent implements OnInit {
connections = [];
constructor(private appsService: AppsService, private routingService: RoutingService, private ref: ChangeDetectorRef) {
constructor(private appsService: AppsService, private ref: ChangeDetectorRef) {
this.refresh();
}
......
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