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