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

fix, 优化 service worker

parent 6758f353
This source diff could not be displayed because it is too large. You can view the blob instead.
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule, JsonpModule } from '@angular/http';
import {
MatAutocompleteModule,
MatButtonModule,
......@@ -37,6 +36,8 @@ import { ToolbarComponent } from './toolbar/toolbar.component';
import { WatchComponent } from './watch/watch.component';
import { WindbotComponent } from './windbot/windbot.component';
import { YGOProService } from './ygopro.service';
import { HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';
@NgModule({
declarations: [
......@@ -55,6 +56,7 @@ import { YGOProService } from './ygopro.service';
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
FormsModule,
HttpModule,
HttpClientModule,
AppRoutingModule,
BrowserAnimationsModule,
MatInputModule,
......@@ -72,7 +74,6 @@ import { YGOProService } from './ygopro.service';
MatSnackBarModule,
MatAutocompleteModule,
ReactiveFormsModule,
JsonpModule,
MatMenuModule,
MatProgressSpinnerModule
],
......
......@@ -5,7 +5,7 @@
<mat-icon>menu</mat-icon>
</button>
<form (submit)="search(key)">
<input type=search placeholder="卡片搜索" name="key" [(ngModel)]="key" matAutocomplete="auto" [formControl]="searchCtrl">
<input type="search" placeholder="卡片搜索" name="key" [(ngModel)]="key" [matAutocomplete]="auto" [formControl]="searchCtrl">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let card of suggestion | async" [value]="card" (onSelectionChange)="search(card)">
......
import { Component, HostBinding } from '@angular/core';
import { FormControl } from '@angular/forms';
import { Http, Jsonp } from '@angular/http';
import { environment } from '../../environments/environment';
import { LoginService } from '../login.service';
import { routerTransition2 } from '../router.animations';
......@@ -9,10 +8,7 @@ import { YGOProService } from '../ygopro.service';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/mergeMap';
import {HttpClient} from '@angular/common/http';
@Component({
selector: 'app-lobby',
......@@ -21,28 +17,26 @@ import 'rxjs/add/operator/mergeMap';
animations: [routerTransition2]
})
export class LobbyComponent {
@HostBinding('@routerTransition2')
animation: '';
@HostBinding('@routerTransition2') animation: '';
version = environment.version;
build: BuildConfig;
searchCtrl = new FormControl();
suggestion = this.searchCtrl.valueChanges.filter(name => name).mergeMap(name => this.jsonp.get('http://www.ourocg.cn/Suggest.aspx', {
params: {callback: 'JSONP_CALLBACK', key: name}
}).map(response => response.json().result));
suggestion = this.searchCtrl.valueChanges
.filter(name => name)
.mergeMap(name => this.http.get(`https://www.ourocg.cn/search/suggest/${name}`));
key: string;
arena_url: string;
constructor(public login: LoginService,
public ygopro: YGOProService,
private http: Http,
private jsonp: Jsonp,
public storage: StorageService) {
constructor(
public login: LoginService,
public ygopro: YGOProService,
private http: HttpClient,
public storage: StorageService
) {
const arena_url = new URL('https://mycard.moe/ygopro/arena');
arena_url.searchParams.set('sso', login.token);
this.arena_url = arena_url.toString();
......
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