Commit 2353a7a4 authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix

parent 24cbe02c
{ {
"name": "mycard-mobile", "name": "mycard-mobile",
"version": "1.0.25", "version": "1.0.26",
"license": "UNLISENCED", "license": "UNLISENCED",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<button id="menu" mat-icon-button (click)="ygopro.openDrawer()"> <button id="menu" mat-icon-button (click)="ygopro.openDrawer()">
<mat-icon>menu</mat-icon> <mat-icon>menu</mat-icon>
</button> </button>
<form (submit)="search(key)"> <form (submit)="search(searchControl.value)">
<input type="search" placeholder="卡片搜索" name="key" [(ngModel)]="key" [matAutocomplete]="auto" [formControl]="searchCtrl"> <input type="search" placeholder="卡片搜索" name="key" [matAutocomplete]="auto" [formControl]="searchControl">
<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)">
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
<mat-card *ngFor="let item of ygopro.topics | async"> <mat-card *ngFor="let item of ygopro.topics | async">
<a [href]="item.url" target="_blank"> <a [href]="item.url" target="_blank">
<mat-card-header> <mat-card-header>
<img *ngIf="item.image_url" mat-card-avatar [src]="item.image_url"> <img *ngIf="item.image_url" mat-card-avatar [src]="item.image_url" referrerpolicy="no-referrer">
<mat-card-title>{{item.title}}</mat-card-title> <mat-card-title>{{item.title}}</mat-card-title>
<mat-card-subtitle>by {{item.last_poster_username}} / {{item.last_posted_at | date}} <mat-card-subtitle>by {{item.last_poster_username}} / {{item.last_posted_at | date}}
</mat-card-subtitle> </mat-card-subtitle>
......
...@@ -7,7 +7,7 @@ import { StorageService } from '../storage.service'; ...@@ -7,7 +7,7 @@ import { StorageService } from '../storage.service';
import { YGOProService } from '../ygopro.service'; import { YGOProService } from '../ygopro.service';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { filter, mergeMap } from 'rxjs/internal/operators'; import { distinctUntilChanged, filter, map, switchMap } from 'rxjs/internal/operators';
@Component({ @Component({
selector: 'app-lobby', selector: 'app-lobby',
...@@ -21,10 +21,12 @@ export class LobbyComponent { ...@@ -21,10 +21,12 @@ export class LobbyComponent {
version = environment.version; version = environment.version;
build: BuildConfig; build: BuildConfig;
searchCtrl = new FormControl(); searchControl = new FormControl();
suggestion = this.searchCtrl.valueChanges.pipe( suggestion = this.searchControl.valueChanges.pipe(
distinctUntilChanged(),
filter(name => name), filter(name => name),
mergeMap(name => this.http.get(`https://www.ourocg.cn/search/suggest/${name}`)) switchMap(name => this.http.get(`https://api.mycard.moe/ygopro/suggest/${name}`)),
map(data => data.map(item => item.value))
); );
key: string; key: string;
......
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