Commit af78fe45 authored by 神楽坂玲奈's avatar 神楽坂玲奈

openDrawer, backHome, share

parent e349c038
<md-toolbar color="primary"> <md-toolbar color="primary">
<button id="menu" md-icon-button> <button id="menu" md-icon-button (click)="ygopro.openDrawer()">
<md-icon>menu</md-icon> <md-icon>menu</md-icon>
</button> </button>
<form (submit)="search(key)"> <form (submit)="search(key)">
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<md-icon fontSet="fa" fontIcon="fa-trophy"></md-icon> <md-icon fontSet="fa" fontIcon="fa-trophy"></md-icon>
<br>决斗数据库</a></md-grid-tile> <br>决斗数据库</a></md-grid-tile>
<md-grid-tile> <md-grid-tile>
<button md-raised-button><span class="icon">233</span><br>直连</button> <button md-raised-button (click)="ygopro.backHome()"><span class="icon">233</span><br>直连</button>
</md-grid-tile> </md-grid-tile>
</md-grid-list> </md-grid-list>
......
...@@ -14,4 +14,8 @@ export class LoginService { ...@@ -14,4 +14,8 @@ export class LoginService {
localStorage.setItem('login', token); localStorage.setItem('login', token);
} }
avatar(username) {
return 'https://ygobbs.com/user_avatar/ygobbs.com/' + username + '/25/1.png';
}
} }
...@@ -42,7 +42,7 @@ export class NewRoomComponent { ...@@ -42,7 +42,7 @@ export class NewRoomComponent {
} }
share(host_password: string) { share(host_password: string) {
this.ygopro.share('房间密码是' + host_password);
} }
} }
.avatar { .avatar {
width: 1em; width: 24px;
height: 1em; height: 24px;
border-radius: 50%;
vertical-align: middle;
} }
.game-title { .game-title {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<ng-container cdkColumnDef="users"> <ng-container cdkColumnDef="users">
<md-header-cell *cdkHeaderCellDef>玩家</md-header-cell> <md-header-cell *cdkHeaderCellDef>玩家</md-header-cell>
<md-cell *cdkCellDef="let room"> <md-cell *cdkCellDef="let room">
<img *ngFor="let user of room.users" class="avatar" [src]="'https://ygobbs.com/user_avatar/ygobbs.com/' + user.username + '/25/1.png'"> <img *ngFor="let user of room.users" class="avatar" [src]="login.avatar(user.username)">
</md-cell> </md-cell>
</ng-container> </ng-container>
......
...@@ -3,6 +3,7 @@ import 'rxjs/add/observable/merge'; ...@@ -3,6 +3,7 @@ import 'rxjs/add/observable/merge';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/startWith'; import 'rxjs/add/operator/startWith';
import 'rxjs/Rx'; import 'rxjs/Rx';
import { LoginService } from '../login.service';
import { RoomListDataSource, YGOProService } from '../ygopro.service'; import { RoomListDataSource, YGOProService } from '../ygopro.service';
@Component({ @Component({
...@@ -14,7 +15,7 @@ export class RoomListComponent { ...@@ -14,7 +15,7 @@ export class RoomListComponent {
displayedColumns = ['title', 'users', 'mode', 'extra']; displayedColumns = ['title', 'users', 'mode', 'extra'];
dataSource = new RoomListDataSource(this.ygopro.servers.filter(server => server.custom)); dataSource = new RoomListDataSource(this.ygopro.servers.filter(server => server.custom));
constructor(public ygopro: YGOProService, private changeDetector: ChangeDetectorRef) { constructor(public login: LoginService, public ygopro: YGOProService, private changeDetector: ChangeDetectorRef) {
} }
ngOnInit() { ngOnInit() {
......
.avatar { .avatar {
width: 1em; width: 24px;
height: 1em; height: 24px;
border-radius: 50%;
vertical-align: middle;
} }
.game-title { .game-title {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<ng-container cdkColumnDef="users"> <ng-container cdkColumnDef="users">
<md-header-cell *cdkHeaderCellDef>玩家</md-header-cell> <md-header-cell *cdkHeaderCellDef>玩家</md-header-cell>
<md-cell *cdkCellDef="let room"> <md-cell *cdkCellDef="let room">
<img *ngFor="let user of room.users" class="avatar" [src]="'https://ygobbs.com/user_avatar/ygobbs.com/' + user.username + '/25/1.png'"> <img *ngFor="let user of room.users" class="avatar" [src]="login.avatar(user.username)">
</md-cell> </md-cell>
</ng-container> </ng-container>
......
import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { LoginService } from '../login.service';
import { RoomListDataSource, YGOProService } from '../ygopro.service'; import { RoomListDataSource, YGOProService } from '../ygopro.service';
@Component({ @Component({
...@@ -11,7 +12,7 @@ export class WatchComponent implements OnInit { ...@@ -11,7 +12,7 @@ export class WatchComponent implements OnInit {
displayedColumns = ['mode', 'title', 'users', 'extra']; displayedColumns = ['mode', 'title', 'users', 'extra'];
dataSource = new RoomListDataSource(this.ygopro.servers, 'started'); dataSource = new RoomListDataSource(this.ygopro.servers, 'started');
constructor(public ygopro: YGOProService, private changeDetector: ChangeDetectorRef) { constructor(public login: LoginService, public ygopro: YGOProService, private changeDetector: ChangeDetectorRef) {
} }
ngOnInit() { ngOnInit() {
......
.avatar {
width: 24px;
height: 24px;
border-radius: 50%;
vertical-align: middle;
}
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
<md-list> <md-list>
<h3 md-subheader>选择对手</h3> <h3 md-subheader>选择对手</h3>
<md-list-item (click)="ygopro.join_windbot()">随机</md-list-item> <md-list-item (click)="ygopro.join_windbot()">
<md-list-item *ngFor="let windbot of ygopro.windbot" (click)="ygopro.join_windbot(windbot)">{{windbot}}</md-list-item> <md-icon md-list-icon>airplanemode_active</md-icon>
<h4 md-line>随机</h4>
</md-list-item>
<md-list-item *ngFor="let windbot of ygopro.windbot" (click)="ygopro.join_windbot(windbot)">
<img md-list-icon [src]="login.avatar(windbot)">
<h4 md-line>{{windbot}}</h4>
</md-list-item>
</md-list> </md-list>
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { LoginService } from '../login.service';
import { YGOProService } from '../ygopro.service'; import { YGOProService } from '../ygopro.service';
@Component({ @Component({
...@@ -8,6 +9,6 @@ import { YGOProService } from '../ygopro.service'; ...@@ -8,6 +9,6 @@ import { YGOProService } from '../ygopro.service';
}) })
export class WindbotComponent { export class WindbotComponent {
constructor(public ygopro: YGOProService) { constructor(public login: LoginService, public ygopro: YGOProService) {
} }
} }
...@@ -233,6 +233,33 @@ export class YGOProService { ...@@ -233,6 +233,33 @@ export class YGOProService {
} }
} }
openDrawer() {
try {
window.ygopro.openDrawer();
} catch (error) {
console.error(error);
alert(JSON.stringify({ method: 'openDrawer', params: [] }));
}
}
backHome() {
try {
window.ygopro.backHome();
} catch (error) {
console.error(error);
alert(JSON.stringify({ method: 'backHome', params: [] }));
}
}
share(text: string) {
try {
window.ygopro.share(text);
} catch (error) {
console.error(error);
alert(JSON.stringify({ method: 'share', params: [text] }));
}
}
} }
...@@ -305,6 +332,9 @@ declare global { ...@@ -305,6 +332,9 @@ declare global {
// 残局模式 // 残局模式
puzzle_mode(): void puzzle_mode(): void
openDrawer(): void
backHome(): void
share(text: string): void
}; };
} }
} }
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