Compare commits
17 Commits
feature/ma
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 8de238028e | |||
| 3522df4066 | |||
| d5803c4a94 | |||
| ca7294c3f7 | |||
| d109ba8974 | |||
| 8f6193b846 | |||
| 448cdcf9c2 | |||
| 9973637a92 | |||
| 7904abd782 | |||
| f53c36bea4 | |||
| 16d631423c | |||
| c8168580d6 | |||
| f3a3344004 | |||
| 3713ac502c | |||
| a81c7535c5 | |||
| 8c9efd4371 | |||
| d710d6bac5 |
BIN
apps/NwaifuAnime/public/pic/Blank-profile.png
Normal file
BIN
apps/NwaifuAnime/public/pic/Blank-profile.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
@@ -1,14 +1,12 @@
|
|||||||
@if (serviceWorkerEnabled) {
|
|
||||||
@if (hasUpdate) {
|
|
||||||
<h1>Update available</h1>
|
|
||||||
<button (click)="update()">Update</button>
|
|
||||||
} @else {
|
|
||||||
<h1>Update not available</h1>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<app-header></app-header>
|
<app-header></app-header>
|
||||||
<div class="h-10"></div>
|
<div class="md:h-12 h-16"></div>
|
||||||
<main>
|
<div
|
||||||
<router-outlet></router-outlet>
|
class="content overflow-y-auto md:h-[calc(100vh-3rem)] h-[calc(100vh-4rem)] flex flex-col justify-between"
|
||||||
</main>
|
>
|
||||||
|
<div class="h-max">
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
</div>
|
||||||
|
<app-footer class="md:mb-0 mb-16 flex-shrink-0"></app-footer>
|
||||||
|
</div>
|
||||||
|
<app-tab-bar></app-tab-bar>
|
||||||
<app-notification></app-notification>
|
<app-notification></app-notification>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
main {
|
.content {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
height: calc(100vh - 3rem);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { RouterModule } from "@angular/router";
|
import { RouterModule } from "@angular/router";
|
||||||
import { AppService } from "./app.service";
|
import { AppService } from "./app.service";
|
||||||
|
import { FooterComponent } from "./components/footer/footer.component";
|
||||||
import { HeaderComponent } from "./components/header/header.component";
|
import { HeaderComponent } from "./components/header/header.component";
|
||||||
import { NotificationComponent } from "./components/notification/notification.component";
|
import { NotificationComponent } from "./components/notification/notification.component";
|
||||||
|
import { TabBarComponent } from "./components/tab-bar/tab-bar.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [RouterModule, HeaderComponent, NotificationComponent, NotificationComponent],
|
imports: [
|
||||||
|
RouterModule,
|
||||||
|
HeaderComponent,
|
||||||
|
NotificationComponent,
|
||||||
|
NotificationComponent,
|
||||||
|
FooterComponent,
|
||||||
|
TabBarComponent,
|
||||||
|
],
|
||||||
selector: "app-root",
|
selector: "app-root",
|
||||||
templateUrl: "./app.component.html",
|
templateUrl: "./app.component.html",
|
||||||
styleUrl: "./app.component.less",
|
styleUrl: "./app.component.less",
|
||||||
@@ -14,17 +23,4 @@ import { NotificationComponent } from "./components/notification/notification.co
|
|||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
title = "NwaifuAnime";
|
title = "NwaifuAnime";
|
||||||
constructor(private sw: AppService) {}
|
|
||||||
|
|
||||||
get hasUpdate() {
|
|
||||||
return this.sw.isUpdateAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
update() {
|
|
||||||
this.sw.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
get serviceWorkerEnabled() {
|
|
||||||
return this.sw.serviceWorkerEnabled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { AuthComponent } from "./components/auth/auth.component";
|
|||||||
import { DetailComponent } from "./components/detail/detail.component";
|
import { DetailComponent } from "./components/detail/detail.component";
|
||||||
import { HomeComponent } from "./components/home/home.component";
|
import { HomeComponent } from "./components/home/home.component";
|
||||||
import { ReaderComponent } from "./components/reader/reader.component";
|
import { ReaderComponent } from "./components/reader/reader.component";
|
||||||
|
import { DmcaComponent } from "./components/dmca/dmca.component";
|
||||||
|
|
||||||
export const appRoutes: Route[] = [
|
export const appRoutes: Route[] = [
|
||||||
{
|
{
|
||||||
@@ -15,4 +16,5 @@ export const appRoutes: Route[] = [
|
|||||||
path: "auth",
|
path: "auth",
|
||||||
component: AuthComponent,
|
component: AuthComponent,
|
||||||
},
|
},
|
||||||
|
{ path: "dmca", component: DmcaComponent },
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -18,13 +18,20 @@
|
|||||||
>
|
>
|
||||||
Сохранить
|
Сохранить
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
(click)="clearToken()"
|
||||||
|
class="hover:bg-slate-600 bg-slate-400 p-3 rounded-md text-white"
|
||||||
|
>
|
||||||
|
Очистить
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Вход через скрипт TamperMonkey. Если нет кнопки, значит вы не установили скрипт
|
Вход через скрипт TamperMonkey. Если нет кнопки, значит вы не установили скрипт
|
||||||
<a
|
<a
|
||||||
href="https://test-front.mangalib.me"
|
href="https://test-front.mangalib.me"
|
||||||
class="hover:bg-slate-600 bg-slate-400 p-3 rounded-md text-white tamperMonkey"
|
class="hover:bg-slate-600 bg-slate-400 px-3 md:py-3 py-1 rounded-md text-white tamperMonkey"
|
||||||
>
|
>
|
||||||
Вход
|
Вход
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ export class AuthComponent implements AfterViewInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearToken() {
|
||||||
|
this.rulibAuthService.deleteToken();
|
||||||
|
if (this.libSocialToken) this.libSocialToken.nativeElement.value = "";
|
||||||
|
this.notificationService.info("Токен успешно удален!", "Вход");
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||||
const { token, service } = params;
|
const { token, service } = params;
|
||||||
|
|||||||
17
apps/NwaifuAnime/src/app/components/dmca/dmca.component.html
Normal file
17
apps/NwaifuAnime/src/app/components/dmca/dmca.component.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<p class="text-3xl ps-[3rem] mt-3">DMCA Disclaimer</p>
|
||||||
|
<div class="h-full px-[3rem] flex flex-col gap-3">
|
||||||
|
<div class="block">
|
||||||
|
<p>На русском:</p>
|
||||||
|
<p>
|
||||||
|
Разработчики этого приложения не имеют никакого отношения к контенту, доступному в приложении.
|
||||||
|
Оно собрано из источников, свободно доступных через любой веб-браузер.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="block">
|
||||||
|
<p>English:</p>
|
||||||
|
<p>
|
||||||
|
The developers of this application does not have any affiliation with the content available in
|
||||||
|
the app. It is collecting from the sources freely available through any web browser.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { Component } from "@angular/core";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-dmca",
|
||||||
|
standalone: true,
|
||||||
|
templateUrl: "./dmca.component.html",
|
||||||
|
styleUrl: "./dmca.component.less",
|
||||||
|
})
|
||||||
|
export class DmcaComponent {}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<div
|
||||||
|
class="footer w-full border-t border-black bg-gray-300 min-h-[3rem] mt-3 px-12 flex flex-row justify-between items-center"
|
||||||
|
>
|
||||||
|
<div class="links flex flex-row flex-start gap-3 items-center">
|
||||||
|
<a routerLink="/dmca" title="DMCA Disclaimer" class="underline">DMCA</a>
|
||||||
|
</div>
|
||||||
|
<a
|
||||||
|
class="underline flex flex-row items-center gap-1"
|
||||||
|
target="_blank"
|
||||||
|
title="Source code"
|
||||||
|
href="https://git.nwaifu.su/neuro_llc/NwaifuWeb/src/branch/dev/apps/NwaifuAnime"
|
||||||
|
>Исходный код <i class="lni lni-git"></i
|
||||||
|
></a>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { ChangeDetectionStrategy, Component } from "@angular/core";
|
||||||
|
import { RouterLink } from "@angular/router";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-footer",
|
||||||
|
templateUrl: "./footer.component.html",
|
||||||
|
styleUrls: ["./footer.component.less"],
|
||||||
|
standalone: true,
|
||||||
|
imports: [RouterLink],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
})
|
||||||
|
export class FooterComponent {}
|
||||||
@@ -1,64 +1,29 @@
|
|||||||
|
<div
|
||||||
|
class="header fixed flex flex-col items-center px-2 justify-start gap-1 md:justify-between top-0 left-0 md:h-12 h-16 bg-gray-700 w-full md:flex-row"
|
||||||
|
>
|
||||||
|
<a routerLink="/" title="Main page"><p class="text-xl text-white">NwaifuAnime</p></a>
|
||||||
|
<app-search-field></app-search-field>
|
||||||
|
<button title="Profile" #profileBtn class="hidden md:block">
|
||||||
|
<div class="profile-btn bg-white rounded-full w-8 h-8 aspect-square ms-3">
|
||||||
|
<img src="pic/Blank-profile.png" alt="Profile pic" class="w-full h-full" />
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
@if (this.swEnabled && this.swHasUpdate) {
|
||||||
|
<button title="Update" (click)="swUpdate()" class="md:w-fit w-full">
|
||||||
|
<div
|
||||||
|
class="h-8 md:w-8 w-full rounded-md bg-green-300 flex flex-col justify-center items-center md:ms-1 ms-0 md:mt-0 mt-2"
|
||||||
|
>
|
||||||
|
<i class="lni lni-download text-gray-700"></i>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
[class]="
|
[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 ' +
|
'profile-menu hidden md:flex flex-col overflow-hidden z-20 rounded-md w-32 bg-white border border-black p-3 h-full fixed ' +
|
||||||
(menuOpened ? 'h-screen' : '')
|
(menuOpened ? 'max-h-32 opacity-100' : 'max-h-0 opacity-0')
|
||||||
"
|
"
|
||||||
|
#profileMenu
|
||||||
>
|
>
|
||||||
<div class="flex justify-between flex-row w-full align-middle h-8 items-center">
|
<a routerLink="/auth" title="Auth page"><p class="hover:text-blue-400">Auth</p></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 -->
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="md:hidden flex justify-center items-center px-2"
|
|
||||||
(click)="changeMenu()"
|
|
||||||
>
|
|
||||||
<i [class]="menuBtnClass"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="flex flex-col md:flex-row md:justify-end justify-center items-center gap-3 md:w-[50vw] h-full w-full"
|
|
||||||
>
|
|
||||||
<!-- Search bar on big screens -->
|
|
||||||
<div [class]="searchBarClass">
|
|
||||||
<input
|
|
||||||
type="search"
|
|
||||||
#searchInput
|
|
||||||
class="outline-none ps-1 text-sm leading-6 w-full border-0 bg-transparent border-r border-gray-700"
|
|
||||||
(keydown.enter)="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')
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
.header {
|
.header {
|
||||||
transition: height 0.3s;
|
transition: height 0.3s;
|
||||||
}
|
}
|
||||||
|
:host {
|
||||||
|
z-index: 20;
|
||||||
|
position: fixed;
|
||||||
|
}
|
||||||
|
.profile-menu {
|
||||||
|
transition: max-height 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,59 +1,68 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
|
import {
|
||||||
import { ActivatedRoute, NavigationEnd, Router, RouterLink } from "@angular/router";
|
AfterViewInit,
|
||||||
import { Subject, filter, takeUntil } from "rxjs";
|
Component,
|
||||||
|
ElementRef,
|
||||||
|
HostListener,
|
||||||
|
OnDestroy,
|
||||||
|
ViewChild,
|
||||||
|
} from "@angular/core";
|
||||||
|
import { RouterLink } from "@angular/router";
|
||||||
|
import { Subject } from "rxjs";
|
||||||
|
import { AppService } from "../../app.service";
|
||||||
|
import { SearchFieldComponent } from "../search-field/search-field.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-header",
|
selector: "app-header",
|
||||||
templateUrl: "./header.component.html",
|
templateUrl: "./header.component.html",
|
||||||
styleUrls: ["./header.component.less"],
|
styleUrls: ["./header.component.less"],
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, RouterLink],
|
imports: [CommonModule, RouterLink, SearchFieldComponent],
|
||||||
})
|
})
|
||||||
export class HeaderComponent implements AfterViewInit, OnDestroy {
|
export class HeaderComponent implements AfterViewInit, OnDestroy {
|
||||||
@ViewChild("searchInput") searchInput: ElementRef<HTMLInputElement> | null = null;
|
|
||||||
menuOpened = false;
|
menuOpened = false;
|
||||||
|
@ViewChild("profileBtn") profileBtn: ElementRef<HTMLButtonElement> | null = null;
|
||||||
|
@ViewChild("profileMenu") profileMenu: ElementRef<HTMLDivElement> | null = null;
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
constructor(
|
|
||||||
private router: Router,
|
constructor(private swService: AppService) {}
|
||||||
private route: ActivatedRoute,
|
|
||||||
) {
|
get swEnabled() {
|
||||||
this.router.events
|
return this.swService.serviceWorkerEnabled;
|
||||||
.pipe(filter((event) => event instanceof NavigationEnd))
|
|
||||||
.pipe(takeUntil(this.destroy$))
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
.subscribe((val: any) => {
|
|
||||||
if (val.url.startsWith("/detail") || val.url.startsWith("/reader")) {
|
|
||||||
this.menuOpened = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
changeMenu() {
|
|
||||||
this.menuOpened = !this.menuOpened;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get menuBtnClass(): string {
|
swUpdate() {
|
||||||
return `lni ${this.menuOpened ? "lni-close" : "lni-menu"} text-white`;
|
this.swService.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
get searchBarClass(): string {
|
get swHasUpdate() {
|
||||||
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"}`;
|
return this.swService.isUpdateAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
search() {
|
@HostListener("window:click", ["$event"])
|
||||||
if (this.searchInput) {
|
toggleProfileMenu(event: MouseEvent) {
|
||||||
const text = this.searchInput.nativeElement.value;
|
if (this.profileBtn && this.profileBtn.nativeElement.contains(event.target as Node)) {
|
||||||
this.router.navigateByUrl(`/?search=${text}`);
|
this.menuOpened = !this.menuOpened;
|
||||||
|
} else {
|
||||||
|
this.menuOpened = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
this.moveProfileMenu();
|
||||||
const search = params["search"];
|
}
|
||||||
if (search && this.searchInput) {
|
|
||||||
this.searchInput.nativeElement.value = search;
|
@HostListener("window:resize")
|
||||||
}
|
moveProfileMenu() {
|
||||||
});
|
if (this.profileBtn && this.profileMenu) {
|
||||||
|
const btnRect = this.profileBtn.nativeElement.getBoundingClientRect();
|
||||||
|
const menuRect = this.profileMenu.nativeElement.getBoundingClientRect();
|
||||||
|
const menuWidth = menuRect.width;
|
||||||
|
const menuX = btnRect.left + btnRect.width / 2 - menuWidth * 0.8;
|
||||||
|
const menuY = btnRect.top + btnRect.height;
|
||||||
|
this.profileMenu.nativeElement.style.left = `${menuX}px`;
|
||||||
|
this.profileMenu.nativeElement.style.top = `calc(${menuY}px + 0.25rem)`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
|||||||
@@ -1,30 +1,101 @@
|
|||||||
<h1>It's home component</h1>
|
|
||||||
@if (!search) {
|
@if (!search) {
|
||||||
@for (popular of popularItems; track popular[0]) {
|
|
||||||
<p class="text-5xl">{{ popular[0] }}</p>
|
|
||||||
@for (popularTitle of popular[1]; track popularTitle.id) {
|
|
||||||
<p>{{ popularTitle.rus_name }}</p>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<div class="flex flex-col items-center w-full px-3">
|
|
||||||
@if (loading) {
|
@if (loading) {
|
||||||
<h1>Loading...</h1>
|
<p class="text-5xl text-center mb-16">Подождите...</p>
|
||||||
|
} @else {
|
||||||
|
<p class="text-5xl text-center mb-10">Популярное:</p>
|
||||||
|
<div class="flex flex-col gap-3 items-center w-full px-4 overflow-x-hidden">
|
||||||
|
@for (popular of popularItems; track popular[0]) {
|
||||||
|
<p class="text-5xl text-center">{{ popular[0] }}</p>
|
||||||
|
<div class="w-full overflow-x-auto py-3">
|
||||||
|
<div class="flex flex-row items-center gap-4 h-[400px] w-max">
|
||||||
|
@for (popularTitle of popular[1]; track popularTitle.id) {
|
||||||
|
<a routerLink="/detail" [queryParams]="{ url: popularTitle.slug_url }" class="h-full">
|
||||||
|
<div
|
||||||
|
class="flex flex-col justify-around border-black rounded-md p-4 w-[400px] items-center border h-full flex-shrink-0"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
[src]="popularTitle.cover.thumbnail"
|
||||||
|
[alt]="popularTitle.slug"
|
||||||
|
class="w-[200px] max-h-[250px] h-auto aspect-auto"
|
||||||
|
/>
|
||||||
|
<p class="text-center">
|
||||||
|
{{
|
||||||
|
popularTitle.rus_name.length > 50
|
||||||
|
? popularTitle.rus_name.slice(0, 50) + "..."
|
||||||
|
: popularTitle.rus_name
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
@if (notFound && !loading) {
|
} @else {
|
||||||
<h1>Not found</h1>
|
<div class="flex justify-center items-center mt-3">
|
||||||
}
|
@if (loading) {
|
||||||
@for (item of items; track $index) {
|
<h1>Loading...</h1>
|
||||||
<a
|
} @else if (notFound && !loading) {
|
||||||
routerLink="/detail"
|
<h1>Not found</h1>
|
||||||
[queryParams]="{ url: item.slug_url }"
|
} @else {
|
||||||
title="{{ item.name }}"
|
<h1>Найдено по запросу "{{ search }}" результатов: {{ items.length }}</h1>
|
||||||
class="mb-6 max-w-[700px] w-full"
|
}
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col items-center justify-start gap-3">
|
||||||
|
<div
|
||||||
|
class="flex md:flex-row flex-col flex-nowrap md:flex-wrap gap-2 justify-start items-center w-full px-3 mt-3 md:mx-12"
|
||||||
>
|
>
|
||||||
<div class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full">
|
@for (item of currentPageItems; track $index) {
|
||||||
<h1>{{ item.rus_name }}</h1>
|
<a
|
||||||
<img [src]="item.cover.thumbnail" [alt]="item.slug" class="w-[200px] h-auto aspect-auto" />
|
routerLink="/detail"
|
||||||
|
[queryParams]="{ url: item.slug_url }"
|
||||||
|
title="{{ item.name }}"
|
||||||
|
class="my-1 max-w-[400px] w-full"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full h-[350px]"
|
||||||
|
>
|
||||||
|
<p class="text-center">
|
||||||
|
{{
|
||||||
|
item.rus_name.length > 50 ? item.rus_name.substring(0, 50) + "..." : item.rus_name
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
<img
|
||||||
|
[src]="item.cover.thumbnail"
|
||||||
|
[alt]="item.slug"
|
||||||
|
class="w-[200px] h-auto max-h-[250px] aspect-auto"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
@if (items.length) {
|
||||||
|
<div class="flex flex-row items-center justify-between w-full px-3">
|
||||||
|
<button
|
||||||
|
[ngClass]="{
|
||||||
|
'bg-slate-600 text-white p-3 rounded-md hover:scale-105': 1,
|
||||||
|
'opacity-15': currentPage === 0,
|
||||||
|
}"
|
||||||
|
[disabled]="currentPage === 0"
|
||||||
|
(click)="previousSearchPage()"
|
||||||
|
>
|
||||||
|
Назад
|
||||||
|
</button>
|
||||||
|
<p>Страница {{ currentPage + 1 }} из {{ maxPages + 1 }}</p>
|
||||||
|
<button
|
||||||
|
[ngClass]="{
|
||||||
|
'bg-slate-600 text-white p-3 rounded-md hover:scale-105': 1,
|
||||||
|
'opacity-15': currentPage === maxPages,
|
||||||
|
}"
|
||||||
|
[disabled]="currentPage === maxPages"
|
||||||
|
*ngIf="currentPage < items.length / 8"
|
||||||
|
(click)="nextSearchPage()"
|
||||||
|
>
|
||||||
|
Вперед
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
}
|
||||||
}
|
</div>
|
||||||
</div>
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input, OnDestroy, OnInit } from "@angular/core";
|
import { Component, Input, OnDestroy, OnInit } from "@angular/core";
|
||||||
import { ActivatedRoute, RouterLink } from "@angular/router";
|
import { ActivatedRoute, Router, RouterLink } from "@angular/router";
|
||||||
import { map, Subject, Subscription, takeUntil } from "rxjs";
|
import { Subject, Subscription, map, takeUntil } from "rxjs";
|
||||||
|
import { RulibAuthService } from "../../services/parsers/rulib/rulib.auth.service";
|
||||||
import { IRuLIBPopular } from "../../services/parsers/rulib/rulib.popular.dto";
|
import { IRuLIBPopular } from "../../services/parsers/rulib/rulib.popular.dto";
|
||||||
import { Datum } from "../../services/parsers/rulib/rulib.search.dto";
|
import { Datum } from "../../services/parsers/rulib/rulib.search.dto";
|
||||||
import { SearchService } from "../../services/search.service";
|
import { SearchService } from "../../services/search.service";
|
||||||
@@ -19,6 +20,7 @@ export class HomeComponent implements OnDestroy, OnInit {
|
|||||||
notFound = false;
|
notFound = false;
|
||||||
search: string = "";
|
search: string = "";
|
||||||
popularItemsMap: Map<string, IRuLIBPopular[]> = new Map<string, IRuLIBPopular[]>();
|
popularItemsMap: Map<string, IRuLIBPopular[]> = new Map<string, IRuLIBPopular[]>();
|
||||||
|
currentPage = 0;
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
private popularSubscription = new Subscription();
|
private popularSubscription = new Subscription();
|
||||||
@@ -26,6 +28,8 @@ export class HomeComponent implements OnDestroy, OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
|
private ruLibAuthService: RulibAuthService,
|
||||||
|
private router: Router,
|
||||||
) {
|
) {
|
||||||
this.searchService.setMangalibParser();
|
this.searchService.setMangalibParser();
|
||||||
}
|
}
|
||||||
@@ -36,15 +40,17 @@ export class HomeComponent implements OnDestroy, OnInit {
|
|||||||
this.popularSubscription.unsubscribe();
|
this.popularSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPopular() {
|
private getPopular(parserName: string) {
|
||||||
if (!this.popularSubscription.closed) this.popularSubscription.unsubscribe();
|
this.searchService
|
||||||
this.popularSubscription = this.searchService
|
|
||||||
.getPopular()
|
.getPopular()
|
||||||
.pipe(map((data) => data as IRuLIBPopular[]))
|
.pipe(
|
||||||
|
map((data) => data as IRuLIBPopular[]),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.popularItemsMap.set(this.searchService.getRuLibName(), data);
|
this.popularItemsMap.set(parserName, data);
|
||||||
console.log(this.popularItemsMap);
|
this.loading = false;
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -52,26 +58,67 @@ export class HomeComponent implements OnDestroy, OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getPopularMangalib() {
|
private getPopularMangalib() {
|
||||||
this.searchService.setMangalibParser();
|
this.searchService.setMangalibParser();
|
||||||
this.getPopular();
|
this.getPopular(this.searchService.getRuLibName());
|
||||||
}
|
}
|
||||||
|
|
||||||
getPopularSlashlib() {
|
private getPopularSlashlib() {
|
||||||
this.searchService.setSlashlibParser();
|
this.ruLibAuthService
|
||||||
this.getPopular();
|
.checkToken(this.ruLibAuthService.getToken())
|
||||||
|
.pipe(takeUntil(this.destroy$))
|
||||||
|
.subscribe((loggedIn) => {
|
||||||
|
if (!loggedIn) return;
|
||||||
|
this.searchService.setSlashlibParser();
|
||||||
|
this.getPopular(this.searchService.getRuLibName());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get popularItems() {
|
get popularItems() {
|
||||||
return this.popularItemsMap.entries();
|
return Array.from(this.popularItemsMap.entries()).sort((a, b) => (a[0] > b[0] ? 1 : -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
get currentPageItems() {
|
||||||
|
return this.items.slice(
|
||||||
|
8 * this.currentPage,
|
||||||
|
Math.min(this.items.length, 8 * (this.currentPage + 1)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get maxPages() {
|
||||||
|
return Math.ceil(this.items.length / 8) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
nextSearchPage() {
|
||||||
|
this.currentPage = Math.min(this.currentPage + 1, Math.ceil(this.items.length / 8) - 1);
|
||||||
|
this.router.navigate([], {
|
||||||
|
queryParams: { page: this.currentPage },
|
||||||
|
relativeTo: this.route,
|
||||||
|
queryParamsHandling: "merge",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
previousSearchPage() {
|
||||||
|
this.currentPage = Math.max(this.currentPage - 1, 0);
|
||||||
|
this.router.navigate([], {
|
||||||
|
queryParams: { page: this.currentPage },
|
||||||
|
relativeTo: this.route,
|
||||||
|
queryParamsHandling: "merge",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||||
|
if (this.search && params["search"] && this.search === params["search"]) return;
|
||||||
this.search = params["search"] ?? "";
|
this.search = params["search"] ?? "";
|
||||||
|
try {
|
||||||
|
this.currentPage = Math.max(0, +params["page"] || 0);
|
||||||
|
} catch {
|
||||||
|
this.currentPage = 0;
|
||||||
|
}
|
||||||
this.items = [];
|
this.items = [];
|
||||||
|
this.loading = true;
|
||||||
if (this.search) {
|
if (this.search) {
|
||||||
this.loading = true;
|
|
||||||
this.searchService.setMangalibParser();
|
this.searchService.setMangalibParser();
|
||||||
this.searchService
|
this.searchService
|
||||||
.search(this.search)
|
.search(this.search)
|
||||||
@@ -79,6 +126,9 @@ export class HomeComponent implements OnDestroy, OnInit {
|
|||||||
.subscribe((data) => {
|
.subscribe((data) => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.items = data.data;
|
this.items = data.data;
|
||||||
|
const maxPage = Math.ceil(this.items.length / 8) - 1;
|
||||||
|
console.log(maxPage);
|
||||||
|
this.currentPage = Math.min(this.currentPage, maxPage);
|
||||||
this.notFound = this.items.length === 0;
|
this.notFound = this.items.length === 0;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -14,7 +14,11 @@
|
|||||||
@if (pages.length > 0 && currentPage) {
|
@if (pages.length > 0 && currentPage) {
|
||||||
<div [class]="imageContainerClass">
|
<div [class]="imageContainerClass">
|
||||||
@if (!isManhwa) {
|
@if (!isManhwa) {
|
||||||
<app-scale-image [imageSrc]="currentPage.imageUrl"></app-scale-image>
|
<app-scale-image
|
||||||
|
[imageSrc]="currentPage.imageUrl"
|
||||||
|
(clickLeft)="prevPage()"
|
||||||
|
(clickRight)="nextPage()"
|
||||||
|
></app-scale-image>
|
||||||
} @else {
|
} @else {
|
||||||
@for (page of manhwaPages; track page.id) {
|
@for (page of manhwaPages; track page.id) {
|
||||||
<app-scale-image
|
<app-scale-image
|
||||||
@@ -26,7 +30,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center justify-center space-x-4 my-10">
|
<div class="flex items-center justify-center space-x-4 mt-[6rem]">
|
||||||
<button (click)="prevPage()" class="p-3 text-white bg-slate-600 w-[100px] rounded-lg">
|
<button (click)="prevPage()" class="p-3 text-white bg-slate-600 w-[100px] rounded-lg">
|
||||||
←
|
←
|
||||||
</button>
|
</button>
|
||||||
@@ -35,8 +39,10 @@
|
|||||||
→
|
→
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden md:block md:fixed right-10 top-[50%]">
|
@if (isManhwa) {
|
||||||
{{ currentPageIndex + 1 }} / {{ pages.length }}
|
<div class="hidden md:block md:fixed right-10 top-[50%]">
|
||||||
</div>
|
{{ currentPageIndex + 1 }} / {{ pages.length }}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
:host {
|
|
||||||
overflow-y: auto;
|
|
||||||
height: 100%;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -240,6 +240,6 @@ export class ReaderComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get imageContainerClass() {
|
get imageContainerClass() {
|
||||||
return `${this.isManhwa ? "h-auto" : "h-[70vh]"} w-[95vw] md:w-[450px] flex flex-col`;
|
return `${this.isManhwa ? "h-auto" : "min-h-[70vh]"} w-screen md:w-[450px] flex flex-col`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div class="image-container" #container>
|
<div class="image-container" #container>
|
||||||
@if (imageSrc) {
|
@if (imageSrc) {
|
||||||
<img #image [src]="imageSrc" (load)="onImageLoad()" alt="Manga page" />
|
<img #image [src]="imageSrc" (load)="onImageLoad()" alt="Manga page" class="cursor-pointer" />
|
||||||
} @else {
|
} @else {
|
||||||
<div class="h-screen flex flex-col items-center justify-center"><h1>Loading...</h1></div>
|
<div class="h-screen flex flex-col items-center justify-center"><h1>Loading...</h1></div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
Output,
|
Output,
|
||||||
|
QueryList,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
|
ViewChildren,
|
||||||
} from "@angular/core";
|
} from "@angular/core";
|
||||||
import { Subscription, debounceTime, fromEvent } from "rxjs";
|
import { Subject, Subscription, debounceTime, fromEvent, map, takeUntil } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-scale-image",
|
selector: "app-scale-image",
|
||||||
@@ -20,10 +22,16 @@ export class ScaleImageComponent implements AfterViewInit, OnDestroy {
|
|||||||
@Input({ required: true }) imageSrc: string = "";
|
@Input({ required: true }) imageSrc: string = "";
|
||||||
@ViewChild("container", { static: true }) containerRef: ElementRef | null = null;
|
@ViewChild("container", { static: true }) containerRef: ElementRef | null = null;
|
||||||
@ViewChild("image", { static: true }) imageRef: ElementRef | null = null;
|
@ViewChild("image", { static: true }) imageRef: ElementRef | null = null;
|
||||||
|
@ViewChildren("image") imageList: QueryList<ElementRef<HTMLImageElement>> = new QueryList<
|
||||||
|
ElementRef<HTMLImageElement>
|
||||||
|
>();
|
||||||
@Output() view = new EventEmitter<void>();
|
@Output() view = new EventEmitter<void>();
|
||||||
|
@Output() clickLeft = new EventEmitter<void>();
|
||||||
|
@Output() clickRight = new EventEmitter<void>();
|
||||||
@Input() host: ElementRef | null = null;
|
@Input() host: ElementRef | null = null;
|
||||||
@Input() hostScrollable: boolean = false;
|
@Input() hostScrollable: boolean = false;
|
||||||
|
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
private resizeSubscription: Subscription = new Subscription();
|
private resizeSubscription: Subscription = new Subscription();
|
||||||
private observer!: IntersectionObserver;
|
private observer!: IntersectionObserver;
|
||||||
|
|
||||||
@@ -39,11 +47,37 @@ export class ScaleImageComponent implements AfterViewInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
if (this.containerRef) this.observer.observe(this.containerRef.nativeElement);
|
if (this.containerRef) this.observer.observe(this.containerRef.nativeElement);
|
||||||
}
|
}
|
||||||
|
if (!this.host) {
|
||||||
|
this.imageList.changes
|
||||||
|
.pipe<QueryList<ElementRef<HTMLImageElement>>>(takeUntil(this.destroy$))
|
||||||
|
.subscribe((imageList) => {
|
||||||
|
fromEvent(imageList.first.nativeElement, "click")
|
||||||
|
.pipe(
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
map((e) => e as MouseEvent),
|
||||||
|
)
|
||||||
|
.subscribe((e) => {
|
||||||
|
const target = e.target as HTMLImageElement;
|
||||||
|
const imageWidth = target.clientWidth;
|
||||||
|
const clickX = e.offsetX;
|
||||||
|
if (clickX < imageWidth / 2) this.clickLeft.emit();
|
||||||
|
else this.clickRight.emit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// fromEvent(this.imageRef.first.nativeElement, "click")
|
||||||
|
// .pipe(takeUntil(this.destroy$))
|
||||||
|
// .subscribe((e) => {
|
||||||
|
// console.log(e);
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.resizeSubscription) this.resizeSubscription.unsubscribe();
|
if (this.resizeSubscription) this.resizeSubscription.unsubscribe();
|
||||||
if (this.observer) this.observer.disconnect();
|
if (this.observer) this.observer.disconnect();
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
onImageLoad() {
|
onImageLoad() {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<div class="flex flex-row gap-3 justify-between items-center md:justify-end">
|
||||||
|
<div
|
||||||
|
[class]="
|
||||||
|
'input-block rounded-md bg-white transition-[width] delay-150 duration-300 ease-in-out h-full overflow-hidden flex justify-center items-center w-full ' +
|
||||||
|
(openSearchField ? 'md:w-[300px]' : 'md:w-0')
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="search"
|
||||||
|
#searchInput
|
||||||
|
class="outline-none ps-1 text-sm leading-6 w-full border-0 bg-transparent border-r border-gray-700"
|
||||||
|
placeholder="Начать поиск"
|
||||||
|
(keydown.enter)="search()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button (click)="toggleSearchField()" class="hidden md:block">
|
||||||
|
<div class="input-btn rounded-full w-8 h-8 bg-slate-400 flex justify-center items-center">
|
||||||
|
<i class="lni lni-search-alt text-white"></i>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
:host {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
|
||||||
|
import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
|
||||||
|
import { Subject, filter, takeUntil } from "rxjs";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-search-field",
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule],
|
||||||
|
templateUrl: "./search-field.component.html",
|
||||||
|
styleUrl: "./search-field.component.less",
|
||||||
|
})
|
||||||
|
export class SearchFieldComponent implements AfterViewInit, OnDestroy {
|
||||||
|
@ViewChild("searchInput") searchInput: ElementRef<HTMLInputElement> | null = null;
|
||||||
|
openSearchField = false;
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||||
|
const search = params["search"];
|
||||||
|
if (search && this.searchInput) {
|
||||||
|
this.searchInput.nativeElement.value = search;
|
||||||
|
this.openSearchField = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.router.events
|
||||||
|
.pipe(
|
||||||
|
filter((event) => event instanceof NavigationEnd),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.subscribe((event: any) => {
|
||||||
|
if (event.url === "/" && this.searchInput) {
|
||||||
|
this.searchInput.nativeElement.value = "";
|
||||||
|
this.openSearchField = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
search() {
|
||||||
|
console.log(this.searchInput);
|
||||||
|
if (this.searchInput && this.searchInput.nativeElement.value)
|
||||||
|
this.router.navigate(["/"], {
|
||||||
|
queryParams: { search: this.searchInput.nativeElement.value },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleSearchField() {
|
||||||
|
this.openSearchField = !this.openSearchField;
|
||||||
|
if (this.openSearchField && this.searchInput) {
|
||||||
|
this.searchInput.nativeElement.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<div
|
||||||
|
class="flex flex-row justify-start items-center md:hidden fixed bottom-0 w-full bg-gray-700 h-16 px-3"
|
||||||
|
>
|
||||||
|
@for (link of links; track link.link) {
|
||||||
|
<a [routerLink]="link.link">
|
||||||
|
<div class="tab-bar__item flex flex-col justify-center items-center h-full center w-16">
|
||||||
|
<i
|
||||||
|
[class]="
|
||||||
|
'text-3xl ' + link.line_icon + ' ' + (link.active ? 'text-white' : 'text-gray-500')
|
||||||
|
"
|
||||||
|
></i>
|
||||||
|
<span [class]="link.active ? 'text-white' : 'text-gray-500'">Auth</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { Component, OnDestroy } from "@angular/core";
|
||||||
|
import { NavigationEnd, Router, RouterLink } from "@angular/router";
|
||||||
|
import { Subject, filter, takeUntil } from "rxjs";
|
||||||
|
import { ITab } from "./tab-bar.dto";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-tab-bar",
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, RouterLink],
|
||||||
|
templateUrl: "./tab-bar.component.html",
|
||||||
|
styleUrl: "./tab-bar.component.less",
|
||||||
|
})
|
||||||
|
export class TabBarComponent implements OnDestroy {
|
||||||
|
links: ITab[] = [
|
||||||
|
{
|
||||||
|
link: "/auth",
|
||||||
|
line_icon: "lni lni-user",
|
||||||
|
name: "Auth",
|
||||||
|
active: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
|
constructor(private router: Router) {
|
||||||
|
this.router.events
|
||||||
|
.pipe(
|
||||||
|
filter((event) => event instanceof NavigationEnd),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.subscribe((event: any) => {
|
||||||
|
this.links.forEach((link) => {
|
||||||
|
link.active = event.url.startsWith(link.link);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export interface ITab {
|
||||||
|
link: string;
|
||||||
|
line_icon: string;
|
||||||
|
name: string;
|
||||||
|
active: boolean;
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@ import { IRulibDetailResult } from "./rulib.detail.dto";
|
|||||||
import { IRuLIBPopular } from "./rulib.popular.dto";
|
import { IRuLIBPopular } from "./rulib.popular.dto";
|
||||||
import { IRulibSearchResult } from "./rulib.search.dto";
|
import { IRulibSearchResult } from "./rulib.search.dto";
|
||||||
|
|
||||||
//TODO: Make abstract classes
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: "root",
|
providedIn: "root",
|
||||||
})
|
})
|
||||||
@@ -101,9 +100,8 @@ export class LibSocialParserService extends Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPopular(): Observable<IRuLIBPopular[]> {
|
getPopular(): Observable<IRuLIBPopular[]> {
|
||||||
//TODO: мб сделать ассинхрон
|
|
||||||
return this.http
|
return this.http
|
||||||
.get<{ data: { popular: [] } }>(`${this.url}/api/`, {
|
.get<{ data: { popular: IRuLIBPopular[] } }>(`${this.url}/api/`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: "Bearer " + this.rulibAuthService.getToken(),
|
Authorization: "Bearer " + this.rulibAuthService.getToken(),
|
||||||
"Site-Id": this.site_id,
|
"Site-Id": this.site_id,
|
||||||
@@ -111,8 +109,7 @@ export class LibSocialParserService extends Parser {
|
|||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
map((data) => {
|
map((data) => {
|
||||||
const res = data.data.popular as IRuLIBPopular[];
|
const res = data.data.popular;
|
||||||
console.log(res);
|
|
||||||
return res;
|
return res;
|
||||||
}),
|
}),
|
||||||
catchError((error) => throwError(() => `Now found ${error}`)),
|
catchError((error) => throwError(() => `Now found ${error}`)),
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ export class RulibAuthService implements OnDestroy {
|
|||||||
return token_data.rulib_token ?? "";
|
return token_data.rulib_token ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteToken(): void {
|
||||||
|
const token_data: IToken = JSON.parse(localStorage.getItem("token") ?? "{}");
|
||||||
|
token_data.rulib_token = "";
|
||||||
|
localStorage.setItem("token", JSON.stringify(token_data));
|
||||||
|
}
|
||||||
|
|
||||||
checkToken(token: string): Observable<boolean> {
|
checkToken(token: string): Observable<boolean> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(this.api_url + "/api/auth/me", {
|
.get(this.api_url + "/api/auth/me", {
|
||||||
|
|||||||
7
nx.json
7
nx.json
@@ -36,5 +36,10 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nxCloudAccessToken": "${NX_CLOUD_ACCESS_TOKEN}"
|
"nxCloudAccessToken": "${NX_CLOUD_ACCESS_TOKEN}",
|
||||||
|
"generators": {
|
||||||
|
"@nx/angular:component": {
|
||||||
|
"style": "less"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nwaifu-web",
|
"name": "nwaifu-web",
|
||||||
"version": "0.2.3",
|
"version": "0.3.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "nx serve NwaifuWeb",
|
"start": "nx serve NwaifuWeb",
|
||||||
|
|||||||
Reference in New Issue
Block a user