diff --git a/apps/NwaifuAnime/src/app/components/auth/auth.component.html b/apps/NwaifuAnime/src/app/components/auth/auth.component.html index 62ea43e..d302926 100644 --- a/apps/NwaifuAnime/src/app/components/auth/auth.component.html +++ b/apps/NwaifuAnime/src/app/components/auth/auth.component.html @@ -31,7 +31,7 @@ Вход через скрипт TamperMonkey. Если нет кнопки, значит вы не установили скрипт Вход diff --git a/apps/NwaifuAnime/src/app/components/home/home.component.html b/apps/NwaifuAnime/src/app/components/home/home.component.html index bcaea84..f853d4c 100644 --- a/apps/NwaifuAnime/src/app/components/home/home.component.html +++ b/apps/NwaifuAnime/src/app/components/home/home.component.html @@ -16,9 +16,15 @@ -

{{ popularTitle.rus_name }}

+

+ {{ + popularTitle.rus_name.length > 50 + ? popularTitle.rus_name.slice(0, 50) + "..." + : popularTitle.rus_name + }} +

} @@ -28,31 +34,46 @@ } } @else { -
+
@if (loading) {

Loading...

- } - @if (notFound && !loading) { + } @else if (notFound && !loading) {

Not found

- } - @for (item of items; track $index) { - -
-

{{ item.rus_name }}

- -
-
+ } @else { +

Найдено по запросу "{{ search }}" результатов: {{ items.length }}

}
+
+ +
+ + +
+
} diff --git a/apps/NwaifuAnime/src/app/components/home/home.component.ts b/apps/NwaifuAnime/src/app/components/home/home.component.ts index 8488457..267c8cf 100644 --- a/apps/NwaifuAnime/src/app/components/home/home.component.ts +++ b/apps/NwaifuAnime/src/app/components/home/home.component.ts @@ -20,6 +20,7 @@ export class HomeComponent implements OnDestroy, OnInit { notFound = false; search: string = ""; popularItemsMap: Map = new Map(); + currentPage = 0; private destroy$ = new Subject(); private popularSubscription = new Subscription(); @@ -79,6 +80,11 @@ export class HomeComponent implements OnDestroy, OnInit { ngOnInit(): void { this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => { this.search = params["search"] ?? ""; + try { + this.currentPage = +params["page"] ?? 0; + } catch { + this.currentPage = 0; + } this.items = []; this.loading = true; if (this.search) { @@ -89,6 +95,8 @@ export class HomeComponent implements OnDestroy, OnInit { .subscribe((data) => { this.loading = false; this.items = data.data; + const maxPage = Math.floor(this.items.length / 8) - 1; + this.currentPage = Math.min(this.currentPage, maxPage); this.notFound = this.items.length === 0; }); } else {