Commit 09e4f886 authored by 神楽坂玲奈's avatar 神楽坂玲奈

lint & update

Signed-off-by: 神楽坂玲奈's avatarzh99998 <zh99998@gmail.com>
parent ec931392
This diff is collapsed.
......@@ -7,42 +7,41 @@
"start": "ng serve --base-href /mobile/ --deploy-url /mobile --locale zh-CN --output-path mobile --open",
"start:wild": "npm run start -- --host 0.0.0.0 --public-host 192.168.1.131:4200",
"build": "ng build --base-href /mobile/ --locale zh-CN --aot --build-optimizer --extract-css --prod",
"postinstall": "./fuck.sh",
"build:dev": "ng build --base-href /mobile2/ --locale zh-CN --aot --build-optimizer --extract-css",
"lint": "ng lint",
"lint": "ng lint --type-check --fix",
"publish": "npm run build && ./ossutil cp -rf dist oss://mycard/mobile",
"publish:dev": "npm run build:dev && ./ossutil cp -rf dist oss://mycard/mobile2"
},
"dependencies": {
"@angular/animations": "^4.3.0",
"@angular/animations": "^4.3.6",
"@angular/cdk": "^2.0.0-beta.8",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/common": "^4.3.6",
"@angular/compiler": "^4.3.6",
"@angular/core": "^4.3.6",
"@angular/forms": "^4.3.6",
"@angular/http": "^4.3.6",
"@angular/material": "^2.0.0-beta.8",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"core-js": "^2.4.1",
"@angular/platform-browser": "^4.3.6",
"@angular/platform-browser-dynamic": "^4.3.6",
"@angular/router": "^4.3.6",
"core-js": "^2.5.0",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"lodash": "^4.17.4",
"material-design-icons": "^3.0.1",
"rxjs": "^5.4.2",
"webdav": "^1.0.0-rc1",
"zone.js": "^0.8.14"
"rxjs": "^5.4.3",
"webdav": "^1.0.1",
"zone.js": "^0.8.17"
},
"devDependencies": {
"@angular/cli": "1.3.0-rc.1",
"@angular/compiler-cli": "^4.2.4",
"@angular/language-service": "^4.2.4",
"@angular/compiler-cli": "^4.3.6",
"@angular/language-service": "^4.3.6",
"@angular/service-worker": "^1.0.0-beta.16",
"@types/lodash": "^4.14.70",
"@types/node": "^8.0.13",
"@types/lodash": "^4.14.74",
"@types/node": "^8.0.24",
"codelyzer": "~3.1.1",
"tslint": "^5.5.0",
"tslint": "^5.6.0",
"typescript": "~2.3.3"
}
}
......@@ -28,9 +28,9 @@ import 'rxjs/Rx';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LobbyComponent } from './lobby/lobby.component';
import { MatchDialog } from './match/match.component';
import { MatchDialogComponent } from './match/match.component';
import { NewRoomComponent } from './new-room/new-room.component';
import { ResultDialog } from './result/result.dialog';
import { ResultDialogComponent } from './result/result.dialog';
import { RoomListComponent } from './room-list/room-list.component';
import { StorageService } from './storage.service';
import { ToolbarComponent } from './toolbar/toolbar.component';
......@@ -44,11 +44,11 @@ import { YGOProService } from './ygopro.service';
LobbyComponent,
NewRoomComponent,
RoomListComponent,
MatchDialog,
MatchDialogComponent,
WindbotComponent,
WatchComponent,
ToolbarComponent,
ResultDialog,
ResultDialogComponent,
],
imports: [
BrowserModule,
......@@ -78,7 +78,7 @@ import { YGOProService } from './ygopro.service';
],
providers: [YGOProService, StorageService],
bootstrap: [AppComponent],
entryComponents: [MatchDialog, ResultDialog],
entryComponents: [MatchDialogComponent, ResultDialogComponent],
})
export class AppModule {
}
......@@ -5,7 +5,7 @@
<md-icon>menu</md-icon>
</button>
<form (submit)="search(key)">
<input type=search placeholder="卡片搜索" name="key" [(ngModel)]="key" [mdAutocomplete]="auto" [formControl]="searchCtrl">
<input type=search placeholder="卡片搜索" name="key" [(ngModel)]="key" mdAutocomplete="auto" [formControl]="searchCtrl">
<md-autocomplete #auto="mdAutocomplete">
<md-option *ngFor="let card of suggestion | async" [value]="card" (onSelectionChange)="search(card)">
......
import { Component } from '@angular/core';
import { Component, HostBinding } from '@angular/core';
import { FormControl } from '@angular/forms';
import { Http, Jsonp } from '@angular/http';
import { MdDialog } from '@angular/material';
import { ActivatedRoute } from '@angular/router';
import { environment } from '../../environments/environment';
import { LoginService } from '../login.service';
import { MatchDialog } from '../match/match.component';
import { routerTransition2 } from '../router.animations';
import { YGOProService } from '../ygopro.service';
import { StorageService } from '../storage.service';
import { YGOProService } from '../ygopro.service';
@Component({
selector: 'app-lobby',
templateUrl: 'lobby.component.html',
styleUrls: ['lobby.component.css'],
animations: [routerTransition2],
host: { '[@routerTransition2]': '' }
animations: [routerTransition2]
})
export class LobbyComponent {
@HostBinding('@routerTransition2')
animation: '';
version = environment.version;
build: BuildConfig;
searchCtrl = new FormControl();
suggestion = this.searchCtrl.valueChanges.filter(name => name).flatMap(name => this.jsonp.get('http://www.ourocg.cn/Suggest.aspx', {
params: { callback: 'JSONP_CALLBACK', key: name }
params: {callback: 'JSONP_CALLBACK', key: name}
}).map(response => response.json().result));
key: string;
arena_url: string;
constructor(public login: LoginService, public ygopro: YGOProService, public dialog: MdDialog, private http: Http, private jsonp: Jsonp, private route: ActivatedRoute, public storage: StorageService) {
constructor(public login: LoginService,
public ygopro: YGOProService,
private http: Http,
private jsonp: Jsonp,
public storage: StorageService) {
const arena_url = new URL('https://mycard.moe/ygopro/arena');
arena_url.searchParams.set('sso', login.token);
......
......@@ -11,9 +11,9 @@ export class LoginService {
login() {
let params = new URLSearchParams();
params.set('return_sso_url', location.href);
let payload = Buffer.from(params.toString()).toString('base64');
const payload = Buffer.from(params.toString()).toString('base64');
let url = new URL('https://accounts.moecube.com');
const url = new URL('https://accounts.moecube.com');
params = url['searchParams'];
params.set('sso', payload);
......@@ -48,9 +48,9 @@ export class LoginService {
logout() {
let params = new URLSearchParams();
params.set('return_sso_url', location.href);
let payload = Buffer.from(params.toString()).toString('base64');
const payload = Buffer.from(params.toString()).toString('base64');
let url = new URL('https://accounts.moecube.com/signin');
const url = new URL('https://accounts.moecube.com/signin');
params = url['searchParams'];
params.set('sso', payload);
return url.toString();
......
......@@ -13,20 +13,25 @@ const offset = new Date().getTimezoneOffset() * 60 * second;
templateUrl: './match.component.html',
styleUrls: ['./match.component.css']
})
export class MatchDialog implements OnInit, OnDestroy {
export class MatchDialogComponent implements OnInit, OnDestroy {
expect_wait = this.http.get('https://api.mycard.moe/ygopro/match/stats/' + this.arena).map(response => response.json() * second + offset);
actual_wait = Observable.timer(0, second).map(timestamp => timestamp * second + offset);
matching: Subscription;
constructor(@Inject(MD_DIALOG_DATA) public arena: string, private dialogRef: MdDialogRef<MatchDialog>, private http: Http, private login: LoginService) {
constructor(@Inject(MD_DIALOG_DATA) public arena: string,
private dialogRef: MdDialogRef<MatchDialogComponent>,
private http: Http,
private login: LoginService) {
}
ngOnInit() {
this.matching = this.http.post('https://api.mycard.moe/ygopro/match', null, {
headers: new Headers({ Authorization: 'Basic ' + Buffer.from(this.login.user.username + ':' + this.login.user.external_id).toString('base64') }),
params: { arena: this.arena, locale: 'zh-CN' }
headers: new Headers({
Authorization: 'Basic ' + Buffer.from(this.login.user.username + ':' + this.login.user.external_id).toString('base64')
}),
params: {arena: this.arena, locale: 'zh-CN'}
}).map(response => response.json()).subscribe((data) => {
this.dialogRef.close(data);
}, (error) => {
......
import { Component, ElementRef, ViewChild } from '@angular/core';
import { Component, ElementRef, HostBinding, ViewChild } from '@angular/core';
import { MdSnackBar } from '@angular/material';
import { LoginService } from '../login.service';
import { routerTransition } from '../router.animations';
......@@ -9,11 +9,13 @@ import { YGOProService } from '../ygopro.service';
selector: 'app-new-room',
templateUrl: 'new-room.component.html',
styleUrls: ['new-room.component.css'],
animations: [routerTransition],
host: { '[@routerTransition]': '' }
animations: [routerTransition]
})
export class NewRoomComponent {
@HostBinding('@routerTransition')
animation = '';
@ViewChild('hostPasswordInput')
hostPasswordInput: ElementRef;
......@@ -22,7 +24,7 @@ export class NewRoomComponent {
room = {
title: this.login.user.username + '的房间',
'private': false,
options: { ...this.ygopro.default_options }
options: {...this.ygopro.default_options}
};
constructor(public ygopro: YGOProService, private login: LoginService, private snackBar: MdSnackBar) {
......@@ -34,7 +36,7 @@ export class NewRoomComponent {
this.hostPasswordInput.nativeElement.select();
if (document.execCommand('copy')) {
this.snackBar.open(`房间密码 ${host_password} 已复制到剪贴板`, undefined, { duration: 3000 });
this.snackBar.open(`房间密码 ${host_password} 已复制到剪贴板`, undefined, {duration: 3000});
} else {
console.log('Oops, unable to copy');
}
......@@ -49,7 +51,7 @@ export class NewRoomComponent {
}
set_start_lp() {
if (this.room.options.mode == 2) {
if (this.room.options.mode === 2) {
this.room.options.start_lp = 16000;
} else {
this.room.options.start_lp = 8000;
......
......@@ -2,20 +2,24 @@ import { Component, Inject } from '@angular/core';
import { Http } from '@angular/http';
import { MD_DIALOG_DATA, MdDialog, MdDialogRef } from '@angular/material';
import { LoginService } from '../login.service';
import { MatchDialog } from '../match/match.component';
import { MatchDialogComponent } from '../match/match.component';
@Component({
selector: 'app-result',
templateUrl: './result.dialog.html',
styleUrls: ['./result.dialog.css']
})
export class ResultDialog {
export class ResultDialogComponent {
result: 'win' | 'lose' | 'draw';
dp: string | undefined;
exp: string | undefined;
firstWin: string | undefined;
constructor(@Inject(MD_DIALOG_DATA) public last: any, public login: LoginService, private http: Http, public dialog: MdDialog, private dialogRef: MdDialogRef<MatchDialog>) {
constructor(@Inject(MD_DIALOG_DATA) public last: any,
public login: LoginService,
private http: Http,
public dialog: MdDialog,
private dialogRef: MdDialogRef<MatchDialogComponent>) {
if (this.last.userscorea === this.last.userscoreb) {
this.result = 'draw';
} else if (this.last.winner === this.login.user.username) {
......@@ -24,7 +28,7 @@ export class ResultDialog {
this.result = 'lose';
}
const index = this.last.usernamea == this.login.user.username ? 'a' : 'b';
const index = this.last.usernamea === this.login.user.username ? 'a' : 'b';
if (this.last.isfirstwin && this.result === 'win') {
this.dp = this.format(this.last[`pt${index}`] - 4, this.last[`pt${index}_ex`]);
......
import { ChangeDetectorRef, Component } from '@angular/core';
import { ChangeDetectorRef, Component, HostBinding, OnInit } from '@angular/core';
import { LoginService } from '../login.service';
import { RoomListDataSource, YGOProService } from '../ygopro.service';
import { routerTransition } from '../router.animations';
import { RoomListDataSource, YGOProService } from '../ygopro.service';
@Component({
selector: 'app-room-list',
styleUrls: ['room-list.component.css'],
templateUrl: 'room-list.component.html',
animations: [routerTransition],
host: {'[@routerTransition]': ''}
animations: [routerTransition]
})
export class RoomListComponent {
export class RoomListComponent implements OnInit {
@HostBinding('@routerTransition')
animation: '';
displayedColumns = ['title', 'users', 'mode', 'extra'];
dataSource = new RoomListDataSource(this.ygopro.servers.filter(server => server.custom));
......
// // import the required animation functions from the angular animations module
// import { trigger, state, animate, transition, style } from '@angular/animations';
//
// export const slideInOutAnimation =
// // trigger name for attaching this animation to an element using the [@triggerName] syntax
// trigger('slideInOutAnimation', [
//
// // end state styles for route container (host)
// state('*', style({
// // the view covers the whole screen with a semi tranparent background
// position: 'fixed',
// top: 0,
// left: 0,
// right: 0,
// bottom: 0,
// backgroundColor: 'rgba(0, 0, 0, 0.8)'
// })),
//
// // route 'enter' transition
// transition(':enter', [
//
// // styles at start of transition
// style({
// // start with the content positioned off the right of the screen,
// // -400% is required instead of -100% because the negative position adds to the width of the element
// right: '-400%',
//
// // start with background opacity set to 0 (invisible)
// backgroundColor: 'rgba(0, 0, 0, 0)'
// }),
//
// // animation and styles at end of transition
// animate('5s ease-in-out', style({
// // transition the right position to 0 which slides the content into view
// right: 0,
//
// // transition the background opacity to 0.8 to fade it in
// backgroundColor: 'rgba(0, 0, 0, 0.8)'
// }))
// ]),
//
// // route 'leave' transition
// transition(':leave', [
// // animation and styles at end of transition
// animate('5s ease-in-out', style({
// // transition the right position to -400% which slides the content out of view
// right: '-400%',
//
// // transition the background opacity to 0 to fade it out
// backgroundColor: 'rgba(0, 0, 0, 0)'
// }))
// ])
// ]);
import { animate, state, style, transition, trigger } from '@angular/animations';
export const routerTransition = trigger('routerTransition', [
state('void', style({ position: 'absolute', width: '100%' })),
state('*', style({ position: 'absolute', width: '100%' })),
state('void', style({position: 'absolute', width: '100%'})),
state('*', style({position: 'absolute', width: '100%'})),
transition(':enter', [ // before 2.1: transition('void => *', [
style({ transform: 'translateX(100%)' }),
animate('.5s ease-in-out', style({ transform: 'translateX(0%)' }))
style({transform: 'translateX(100%)'}),
animate('.5s ease-in-out', style({transform: 'translateX(0%)'}))
]),
transition(':leave', [ // before 2.1: transition('* => void', [
style({ transform: 'translateX(0%)' }),
animate('.5s ease-in-out', style({ transform: 'translateX(100%)' }))
style({transform: 'translateX(0%)'}),
animate('.5s ease-in-out', style({transform: 'translateX(100%)'}))
])
]);
export const routerTransition2 = trigger('routerTransition2', [
state('void', style({ position: 'absolute', width: '100%' })),
state('*', style({ position: 'absolute', width: '100%' })),
state('void', style({position: 'absolute', width: '100%'})),
state('*', style({position: 'absolute', width: '100%'})),
transition(':enter', [ // before 2.1: transition('void => *', [
style({ transform: 'translateX(-100%)' }),
animate('.5s ease-in-out', style({ transform: 'translateX(0%)' }))
style({transform: 'translateX(-100%)'}),
animate('.5s ease-in-out', style({transform: 'translateX(0%)'}))
]),
transition(':leave', [ // before 2.1: transition('* => void', [
style({ transform: 'translateX(0%)' }),
animate('.5s ease-in-out', style({ transform: 'translateX(-100%)' }))
style({transform: 'translateX(0%)'}),
animate('.5s ease-in-out', style({transform: 'translateX(-100%)'}))
])
]);
......@@ -4,24 +4,24 @@ import * as webdav from 'webdav';
import { LoginService } from './login.service';
interface DirectoryStats {
'filename': string,
'basename': string,
'lastmod': string,
'size': 0,
'type': 'directory'
'filename': string;
'basename': string;
'lastmod': string;
'size': 0;
'type': 'directory';
}
interface FileStats {
'filename': string,
'basename': string,
'lastmod': string,
'size': number,
'type': 'file',
'mime': string
'filename': string;
'basename': string;
'lastmod': string;
'size': number;
'type': 'file';
'mime': string;
}
type Stats = DirectoryStats | FileStats
type Stats = DirectoryStats | FileStats;
@Injectable()
export class StorageService {
......@@ -168,7 +168,7 @@ export class StorageService {
async * walk(dir: string): AsyncIterable<Stats> {
const items: Stats[] = await this.client.getDirectoryContents(dir);
// console.log('取远端目录', dir, items);
for (let item of items) {
for (const item of items) {
if (item.type === 'directory') {
yield* this.walk(item.filename);
} else {
......
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { ChangeDetectorRef, Component, HostBinding, OnInit } from '@angular/core';
import { LoginService } from '../login.service';
import { RoomListDataSource, YGOProService } from '../ygopro.service';
import { routerTransition } from '../router.animations';
import { RoomListDataSource, YGOProService } from '../ygopro.service';
@Component({
selector: 'app-watch',
templateUrl: './watch.component.html',
styleUrls: ['./watch.component.css'],
animations: [routerTransition],
host: {'[@routerTransition]': ''}
animations: [routerTransition]
})
export class WatchComponent implements OnInit {
@HostBinding('@routerTransition')
animation = '';
displayedColumns = ['mode', 'title', 'users', 'extra'];
dataSource = new RoomListDataSource(this.ygopro.servers, 'started');
......
import { Component } from '@angular/core';
import { Component, HostBinding } from '@angular/core';
import { LoginService } from '../login.service';
import { YGOProService } from '../ygopro.service';
import { routerTransition } from '../router.animations';
import { YGOProService } from '../ygopro.service';
@Component({
selector: 'app-windbot',
templateUrl: './windbot.component.html',
styleUrls: ['./windbot.component.css'],
animations: [routerTransition],
host: {'[@routerTransition]': ''}
animations: [routerTransition]
})
export class WindbotComponent {
@HostBinding('@routerTransition')
animation = '';
constructor(public login: LoginService, public ygopro: YGOProService) {
}
......
This diff is collapsed.
......@@ -41,7 +41,7 @@
// import 'core-js/es6/reflect';
// import 'core-js/es7/reflect';
import 'core-js/shim'
import 'core-js/shim';
/**
* Required to support Web Animations `@angular/animation`.
......
......@@ -41,7 +41,7 @@
}
],
"no-arg": true,
"no-bitwise": true,
"no-bitwise": false,
"no-console": [
true,
"debug",
......@@ -61,7 +61,7 @@
"ignore-params"
],
"no-misused-new": true,
"no-non-null-assertion": true,
"no-non-null-assertion": false,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
......@@ -84,7 +84,7 @@
true,
"single"
],
"radix": true,
"radix": false,
"semicolon": [
true,
"always"
......
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