feat: initial version of reader

This commit is contained in:
2024-07-06 00:53:46 +03:00
parent 2660aef473
commit 55e729422b
12 changed files with 283 additions and 9 deletions

View File

@@ -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(["/"]);
}
});
}
}