Compare commits
3 Commits
c427c6d0b4
...
00213d25a1
| Author | SHA1 | Date | |
|---|---|---|---|
| 00213d25a1 | |||
| 5465d1635c | |||
| d414223df2 |
@@ -1,28 +1,64 @@
|
|||||||
<div
|
<div
|
||||||
class="header fixed flex justify-between w-full p-2 bg-gray-700 md:h-8 items-center md:flex-row flex-col md:gap-0 gap-3 text-xl md:text-base"
|
[class]="
|
||||||
|
'header fixed flex justify-between w-full px-2 bg-gray-700 md:h-8 items-center md:flex-row flex-col md:gap-0 gap-3 text-xl md:text-base ' +
|
||||||
|
(menuOpened ? 'h-screen' : '')
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<div class="flex justify-between flex-row w-full align-middle">
|
<div class="flex justify-between flex-row w-full align-middle h-8 items-center">
|
||||||
<a href="/"><h1 class="text-white" title="Main page">NwaifuAnime</h1></a>
|
<div class="flex flex-row gap-3 h-full items-center">
|
||||||
|
<a routerLink="/" class="h-full px-2 flex justify-center items-center justify-self-center"
|
||||||
|
><h1 class="text-white" title="Main page">NwaifuAnime</h1></a
|
||||||
|
>
|
||||||
|
<div class="border-l border-white h-full"></div>
|
||||||
|
<div class="flex-row gap-3 md:flex hidden h-full items-center">
|
||||||
|
<a
|
||||||
|
routerLink="/auth"
|
||||||
|
class="h-full px-2 flex justify-center items-center hover:bg-gray-600 transition ease-in-out delay-150 duration-300"
|
||||||
|
><h2 class="text-white" title="Auth page">Auth</h2></a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Search bar on small screens -->
|
<!-- Search bar on small screens -->
|
||||||
<button type="button" class="md:hidden" (click)="changeMenu()">
|
<button
|
||||||
|
type="button"
|
||||||
|
class="md:hidden flex justify-center items-center px-2"
|
||||||
|
(click)="changeMenu()"
|
||||||
|
>
|
||||||
<i [class]="menuBtnClass"></i>
|
<i [class]="menuBtnClass"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Search bar on big screens -->
|
<div
|
||||||
<div [class]="searchBarClass">
|
class="flex flex-col md:flex-row md:justify-end justify-center items-center gap-3 md:w-[50vw] h-full w-full"
|
||||||
<input
|
>
|
||||||
type="search"
|
<!-- Search bar on big screens -->
|
||||||
#searchInput
|
<div [class]="searchBarClass">
|
||||||
class="outline-none ps-1 text-sm leading-6 w-full border-0 bg-transparent border-r border-gray-700"
|
<input
|
||||||
(keydown.enter)="search()"
|
type="search"
|
||||||
/>
|
#searchInput
|
||||||
<button
|
class="outline-none ps-1 text-sm leading-6 w-full border-0 bg-transparent border-r border-gray-700"
|
||||||
class="align-middle w-[100px] text-center border-0 flex flex-col items-center justify-center"
|
(keydown.enter)="search()"
|
||||||
type="submit"
|
/>
|
||||||
(click)="search()"
|
<button
|
||||||
|
class="align-middle w-[100px] text-center border-0 flex flex-col items-center justify-center"
|
||||||
|
type="submit"
|
||||||
|
(click)="search()"
|
||||||
|
>
|
||||||
|
<span class="text-sm text-black h-full">Поиск</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
[class]="
|
||||||
|
'flex flex-col w-full justify-start items-center md:hidden overflow-hidden ' +
|
||||||
|
(menuOpened ? 'h-auto' : 'h-0')
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<span class="text-sm text-black h-full">Поиск</span>
|
<a
|
||||||
</button>
|
routerLink="/auth"
|
||||||
|
class="h-full px-2 flex justify-center items-center hover:bg-gray-600 transition ease-in-out delay-150 duration-300"
|
||||||
|
><h2 class="text-white" title="Auth page">Auth</h2></a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
|
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
|
||||||
import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
|
import { ActivatedRoute, NavigationEnd, Router, RouterLink } from "@angular/router";
|
||||||
import { Subject, filter, takeUntil } from "rxjs";
|
import { Subject, filter, takeUntil } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -8,7 +8,7 @@ import { Subject, filter, takeUntil } from "rxjs";
|
|||||||
templateUrl: "./header.component.html",
|
templateUrl: "./header.component.html",
|
||||||
styleUrls: ["./header.component.less"],
|
styleUrls: ["./header.component.less"],
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule],
|
imports: [CommonModule, RouterLink],
|
||||||
})
|
})
|
||||||
export class HeaderComponent implements AfterViewInit, OnDestroy {
|
export class HeaderComponent implements AfterViewInit, OnDestroy {
|
||||||
@ViewChild("searchInput") searchInput: ElementRef<HTMLInputElement> | null = null;
|
@ViewChild("searchInput") searchInput: ElementRef<HTMLInputElement> | null = null;
|
||||||
@@ -37,7 +37,7 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get searchBarClass(): string {
|
get searchBarClass(): string {
|
||||||
return `search-bar bg-slate-300 md:w-[50%] w-full md:m-0 ms-2 me-2 md:h-6 h-10 md:flex justify-start flex-row items-center rounded-md ${this.menuOpened ? "flex" : "hidden"}`;
|
return `search-bar bg-slate-300 md:w-full w-full md:m-0 ms-2 me-2 md:h-6 h-10 md:flex justify-start flex-row items-center rounded-md ${this.menuOpened ? "flex" : "hidden"}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
search() {
|
search() {
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<h1>It's home component</h1>
|
<h1>It's home component</h1>
|
||||||
<div class="flex flex-col items-center w-full px-3">
|
<div class="flex flex-col items-center w-full px-3">
|
||||||
|
@if (loading) {
|
||||||
|
<h1>Loading...</h1>
|
||||||
|
}
|
||||||
|
@if (notFound && !loading) {
|
||||||
|
<h1>Not found</h1>
|
||||||
|
}
|
||||||
@for (item of items; track $index) {
|
@for (item of items; track $index) {
|
||||||
<a
|
<a
|
||||||
routerLink="/detail"
|
routerLink="/detail"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { AfterViewInit, Component, Input, OnDestroy } from "@angular/core";
|
import { Component, Input, OnDestroy, OnInit } from "@angular/core";
|
||||||
import { ActivatedRoute, RouterLink } from "@angular/router";
|
import { ActivatedRoute, RouterLink } from "@angular/router";
|
||||||
import { Subject, takeUntil } from "rxjs";
|
import { Subject, takeUntil } from "rxjs";
|
||||||
import { Datum } from "../../services/parsers/rulib/rulib.search.dto";
|
import { Datum } from "../../services/parsers/rulib/rulib.search.dto";
|
||||||
@@ -12,8 +12,10 @@ import { SearchService } from "../../services/search.service";
|
|||||||
styleUrls: ["./home.component.less"],
|
styleUrls: ["./home.component.less"],
|
||||||
imports: [CommonModule, RouterLink],
|
imports: [CommonModule, RouterLink],
|
||||||
})
|
})
|
||||||
export class HomeComponent implements OnDestroy, AfterViewInit {
|
export class HomeComponent implements OnDestroy, OnInit {
|
||||||
@Input() items: Datum[] = [];
|
@Input() items: Datum[] = [];
|
||||||
|
loading = false;
|
||||||
|
notFound = false;
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
@@ -27,15 +29,18 @@ export class HomeComponent implements OnDestroy, AfterViewInit {
|
|||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.queryParams.subscribe((params) => {
|
this.route.queryParams.subscribe((params) => {
|
||||||
const search = params["search"];
|
const search = params["search"];
|
||||||
if (search) {
|
if (search) {
|
||||||
|
this.loading = true;
|
||||||
this.searchService
|
this.searchService
|
||||||
.search(search)
|
.search(search)
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe((data) => {
|
.subscribe((data) => {
|
||||||
|
this.loading = false;
|
||||||
this.items = data.data;
|
this.items = data.data;
|
||||||
|
this.notFound = this.items.length === 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { CommonModule, isPlatformBrowser } from "@angular/common";
|
import { CommonModule, isPlatformBrowser } from "@angular/common";
|
||||||
import {
|
import {
|
||||||
AfterViewInit,
|
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
HostListener,
|
HostListener,
|
||||||
Inject,
|
Inject,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
|
OnInit,
|
||||||
PLATFORM_ID,
|
PLATFORM_ID,
|
||||||
} from "@angular/core";
|
} from "@angular/core";
|
||||||
import { ActivatedRoute, Router, RouterLink } from "@angular/router";
|
import { ActivatedRoute, Router, RouterLink } from "@angular/router";
|
||||||
@@ -23,7 +23,7 @@ import { CachedPage, CachedPages } from "./reader.dto";
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, ScaleImageComponent, RouterLink],
|
imports: [CommonModule, ScaleImageComponent, RouterLink],
|
||||||
})
|
})
|
||||||
export class ReaderComponent implements AfterViewInit, OnDestroy {
|
export class ReaderComponent implements OnInit, OnDestroy {
|
||||||
//FIXME: Scrolling to top when manhwa
|
//FIXME: Scrolling to top when manhwa
|
||||||
pages: Page[] = [];
|
pages: Page[] = [];
|
||||||
currentPageIndex = 0;
|
currentPageIndex = 0;
|
||||||
@@ -54,7 +54,7 @@ export class ReaderComponent implements AfterViewInit, OnDestroy {
|
|||||||
return this.cachedPages.values();
|
return this.cachedPages.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||||
const url = params["url"];
|
const url = params["url"];
|
||||||
const chapter = params["chapter"];
|
const chapter = params["chapter"];
|
||||||
@@ -166,7 +166,9 @@ export class ReaderComponent implements AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
private clearCache(index: number) {
|
private clearCache(index: number) {
|
||||||
for (let i = 0; i <= index; i++) {
|
for (let i = 0; i <= index; i++) {
|
||||||
|
const imgUrl = this.cachedPages.get(i)!.imageUrl;
|
||||||
this.cachedPages.get(i)!.imageUrl = "";
|
this.cachedPages.get(i)!.imageUrl = "";
|
||||||
|
URL.revokeObjectURL(imgUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export class ScaleImageComponent implements AfterViewInit, OnDestroy {
|
|||||||
([entry]) => entry.isIntersecting && this.view.emit(),
|
([entry]) => entry.isIntersecting && this.view.emit(),
|
||||||
{
|
{
|
||||||
root: this.hostScrollable ? this.host.nativeElement : null,
|
root: this.hostScrollable ? this.host.nativeElement : null,
|
||||||
rootMargin: "1000px",
|
rootMargin: "100px",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (this.containerRef) this.observer.observe(this.containerRef.nativeElement);
|
if (this.containerRef) this.observer.observe(this.containerRef.nativeElement);
|
||||||
|
|||||||
Reference in New Issue
Block a user