feat: initial version of reader
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
@if (detail_item) {
|
||||
<h1>{{ detail_item.name }}</h1>
|
||||
<h2>{{ detail_item.rus_name }}</h2>
|
||||
}
|
||||
<div class="flex flex-col items-center">
|
||||
@if (detail_item) {
|
||||
<h1>{{ detail_item.name }}</h1>
|
||||
<h2>{{ detail_item.rus_name }}</h2>
|
||||
<img [src]="detail_item.cover.default" [alt]="detail_item.slug" />
|
||||
@for (chapter of chapters.data; track $index) {
|
||||
<h3>
|
||||
<strong>{{ chapter.number }}.</strong> {{ chapter.name || "Нет названия" }}
|
||||
</h3>
|
||||
}
|
||||
<button class="p-3 text-white bg-slate-600 w-[400px] mt-5 rounded-lg" (click)="goToReader()">
|
||||
Читать
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { IRulibChaptersResult } from "../../services/parsers/rulib/rulib.chapters.dto";
|
||||
import { Data } from "../../services/parsers/rulib/rulib.detail.dto";
|
||||
import { SearchService } from "../../services/search.service";
|
||||
|
||||
@@ -13,20 +14,41 @@ import { SearchService } from "../../services/search.service";
|
||||
})
|
||||
export class DetailComponent implements AfterViewInit {
|
||||
detail_item: Data | null = null;
|
||||
chapters: IRulibChaptersResult = { data: [] };
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private searchService: SearchService,
|
||||
private router: Router,
|
||||
) {}
|
||||
|
||||
private getDetails(url: string) {
|
||||
this.searchService.getDetails(url).subscribe((data) => {
|
||||
this.detail_item = data.data;
|
||||
});
|
||||
this.searchService.getChapters(url).subscribe((data) => {
|
||||
this.chapters = data;
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
const url = params["url"];
|
||||
if (url) {
|
||||
this.searchService.getDetails(url).subscribe((data) => (this.detail_item = data.data));
|
||||
this.getDetails(url);
|
||||
} else {
|
||||
this.router.navigate(["/"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
goToReader() {
|
||||
//TODO: Not only first chapter
|
||||
this.router.navigate(["/", "reader"], {
|
||||
queryParams: {
|
||||
url: this.detail_item?.slug_url,
|
||||
chapter: this.chapters.data[0].number,
|
||||
volume: this.chapters.data[0].volume,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
class="header fixed flex justify-between w-full p-2 bg-gray-700 md:h-8 h-auto items-center md:flex-row flex-col md:gap-0 gap-3"
|
||||
>
|
||||
<div class="flex justify-between flex-row w-full align-middle">
|
||||
<a href="/"><h1 class="text-white">NwaifuAnime</h1></a>
|
||||
<a href="/"><h1 class="text-white" title="Main page">NwaifuAnime</h1></a>
|
||||
<!-- Search bar on small screens -->
|
||||
<button type="button" class="md:hidden" (click)="changeMenu()">
|
||||
<i [class]="menuBtnClass"></i>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<h1>It's home component</h1>
|
||||
<div class="flex flex-col items-center">
|
||||
@for (item of items; track $index) {
|
||||
<button (click)="getDetails(item.slug)">
|
||||
<div class="card flex flex-col items-center">
|
||||
<button (click)="getDetails(item.slug_url)" title="{{ item.name }}" class="mb-6">
|
||||
<div class="card flex flex-col items-center border-black border-2 rounded-md p-4">
|
||||
<h1>{{ item.rus_name }}</h1>
|
||||
<img [src]="item.cover.thumbnail" [alt]="item.slug" />
|
||||
<img [src]="item.cover.thumbnail" [alt]="item.slug" class="w-[200px] h-auto aspect-auto" />
|
||||
</div>
|
||||
</button>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<h1>It's reader page</h1>
|
||||
<div class="flex flex-col items-center">
|
||||
@for (page of pages; track $index) {
|
||||
<img [src]="page.url" [alt]="page.slug" />
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,38 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Page } from "../../services/parsers/rulib/rulib.chapter.dto";
|
||||
import { SearchService } from "../../services/search.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-reader",
|
||||
templateUrl: "./reader.component.html",
|
||||
styleUrls: ["./reader.component.less"],
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
})
|
||||
export class ReaderComponent implements AfterViewInit {
|
||||
pages: Page[] = [];
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private searchService: SearchService,
|
||||
) {}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
const url = params["url"];
|
||||
const chapter = params["chapter"];
|
||||
const volume = params["volume"];
|
||||
if (url && chapter && volume) {
|
||||
this.searchService.getChapter(url, chapter, volume).subscribe((data) => {
|
||||
this.pages = data.data.pages.map((page) => {
|
||||
return { ...page, url: this.searchService.getImageServer() + page.url };
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.router.navigate(["/"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user