Compare commits
65 Commits
v0.0.1-hot
...
feature/ma
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b209077ef | |||
| 2becf42487 | |||
| 7b2c6d9fc8 | |||
| 00213d25a1 | |||
| 5465d1635c | |||
| d414223df2 | |||
| c427c6d0b4 | |||
| 4105933098 | |||
| 0fea62b639 | |||
| e040edb5bd | |||
| 8c87401482 | |||
| c9c959ce76 | |||
| 45389364ff | |||
| 5a4206a81e | |||
| 35ff603849 | |||
| ccbd9b2f5c | |||
| 03b200c829 | |||
| d1e32a94ca | |||
| 82a0ba102d | |||
| 112e76ab45 | |||
| 6833105604 | |||
| 9d2373a298 | |||
| e6da8b17a7 | |||
| 29fb7fd04d | |||
| 8f5f12ad30 | |||
| 6bad651312 | |||
| 55e729422b | |||
| 2660aef473 | |||
| 7eff09765b | |||
| 37149c83c4 | |||
| c7d76419f7 | |||
| 6ddb3bad29 | |||
| 16a6a05d89 | |||
| f1cbd9267c | |||
| 1929760e82 | |||
| 167e5c4f65 | |||
| 40c9ca38b9 | |||
| 6bb99f6e0e | |||
| 53fee00315 | |||
| c508caab7b | |||
| e90a1bb6ec | |||
| 27f023964f | |||
| b43c8db305 | |||
| e3fc28e440 | |||
| c9638403ab | |||
| 02ae9c6745 | |||
| c8cb378123 | |||
| 47060bcb2d | |||
| fb3acd5182 | |||
| cb1d7e24b7 | |||
| 0d6a56c9a3 | |||
| 7cc5cbaac3 | |||
| cf6128c248 | |||
| 1fd6dd632e | |||
| e291379602 | |||
| 1237ee4439 | |||
| 935d1f5dd9 | |||
| 2a31e85e50 | |||
| c4665737dc | |||
| e3dac5bc83 | |||
| 90582949d5 | |||
| a9436a5af7 | |||
| 8cd5dd1f8e | |||
| f9a7b812fe | |||
| 4d09e6ee11 |
@@ -1,13 +1,9 @@
|
||||
{
|
||||
"root": true,
|
||||
"ignorePatterns": [
|
||||
"projects/**/*"
|
||||
],
|
||||
"ignorePatterns": ["**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.ts"
|
||||
],
|
||||
"files": ["*.ts"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
@@ -34,14 +30,31 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.html"
|
||||
],
|
||||
"files": ["*.html"],
|
||||
"extends": [
|
||||
"plugin:@angular-eslint/template/recommended",
|
||||
"plugin:@angular-eslint/template/accessibility"
|
||||
],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {
|
||||
"@nx/enforce-module-boundaries": [
|
||||
"error",
|
||||
{
|
||||
"enforceBuildableLibDependency": true,
|
||||
"allow": [],
|
||||
"depConstraints": [
|
||||
{
|
||||
"sourceTag": "*",
|
||||
"onlyDependOnLibsWithTags": ["*"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"plugins": ["@nx"]
|
||||
}
|
||||
|
||||
8
.gitignore
vendored
@@ -40,3 +40,11 @@ testem.log
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
|
||||
.nx/cache
|
||||
.nx/workspace-data
|
||||
|
||||
# env
|
||||
*.env*
|
||||
!*.env.example
|
||||
|
||||
5
.prettierignore
Normal file
@@ -0,0 +1,5 @@
|
||||
# Add files here to ignore them from prettier formatting
|
||||
/dist
|
||||
/coverage
|
||||
/.nx/cache
|
||||
/.nx/workspace-data
|
||||
8
.vscode/extensions.json
vendored
@@ -1,4 +1,8 @@
|
||||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
|
||||
"recommendations": ["angular.ng-template"]
|
||||
"recommendations": [
|
||||
"angular.ng-template",
|
||||
"nrwl.angular-console",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode"
|
||||
]
|
||||
}
|
||||
|
||||
10
.vscode/settings.json
vendored
@@ -6,7 +6,11 @@
|
||||
"**/CVS": true,
|
||||
"**/.DS_Store": true,
|
||||
"**/Thumbs.db": true,
|
||||
"**/node_modules": true,
|
||||
"**/.angular": true,
|
||||
}
|
||||
// "**/node_modules": true,
|
||||
"**/.angular": true
|
||||
},
|
||||
"editor.formatOnSave": true,
|
||||
"cSpell.words": [
|
||||
"Manhwa"
|
||||
]
|
||||
}
|
||||
24
README.md
@@ -2,26 +2,6 @@
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.2.2.
|
||||
|
||||
## Development server
|
||||
## Visitor counter
|
||||
|
||||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||
|
||||
## Build
|
||||
|
||||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
|
||||
|
||||
## Further help
|
||||
|
||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
||||

|
||||
|
||||
116
angular.json
@@ -1,116 +0,0 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"cli": {
|
||||
"packageManager": "pnpm",
|
||||
"schematicCollections": [
|
||||
"@angular-eslint/schematics"
|
||||
]
|
||||
},
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"NwaifuWeb": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"style": "less"
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"options": {
|
||||
"outputPath": "dist/nwaifu-web",
|
||||
"index": "src/index.html",
|
||||
"browser": "src/main.ts",
|
||||
"polyfills": [
|
||||
"zone.js"
|
||||
],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"inlineStyleLanguage": "less",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.less"
|
||||
],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "NwaifuWeb:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "NwaifuWeb:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "NwaifuWeb:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
"zone.js/testing"
|
||||
],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "less",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.less"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-eslint/builder:lint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.html"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
apps/NwaifuAnime/.eslintrc.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"extends": ["../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "app",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "app",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.html"],
|
||||
"extends": ["plugin:@nx/angular-template"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
29
apps/NwaifuAnime/ngsw-config.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "../../node_modules/@angular/service-worker/config/schema.json",
|
||||
"index": "/index.html",
|
||||
"assetGroups": [
|
||||
{
|
||||
"name": "app",
|
||||
"installMode": "prefetch",
|
||||
"resources": {
|
||||
"files": [
|
||||
"/favicon.ico",
|
||||
"/index.html",
|
||||
"/manifest.webmanifest",
|
||||
"/*.css",
|
||||
"/*.js"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "assets",
|
||||
"installMode": "lazy",
|
||||
"updateMode": "prefetch",
|
||||
"resources": {
|
||||
"files": [
|
||||
"/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
75
apps/NwaifuAnime/project.json
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"name": "NwaifuAnime",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"prefix": "app",
|
||||
"sourceRoot": "apps/NwaifuAnime/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@angular-devkit/build-angular:application",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"outputPath": "dist/apps/NwaifuAnime",
|
||||
"index": "apps/NwaifuAnime/src/index.html",
|
||||
"browser": "apps/NwaifuAnime/src/main.ts",
|
||||
"polyfills": ["zone.js"],
|
||||
"tsConfig": "apps/NwaifuAnime/tsconfig.app.json",
|
||||
"inlineStyleLanguage": "less",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "apps/NwaifuAnime/public"
|
||||
}
|
||||
],
|
||||
"styles": ["apps/NwaifuAnime/src/styles.less"],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all",
|
||||
"serviceWorker": "apps/NwaifuAnime/ngsw-config.json"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "NwaifuAnime:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "NwaifuAnime:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "NwaifuAnime:build"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint"
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
apps/NwaifuAnime/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
apps/NwaifuAnime/public/icons/icon-128x128.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
apps/NwaifuAnime/public/icons/icon-144x144.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
apps/NwaifuAnime/public/icons/icon-152x152.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
apps/NwaifuAnime/public/icons/icon-192x192.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
apps/NwaifuAnime/public/icons/icon-384x384.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
apps/NwaifuAnime/public/icons/icon-512x512.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
apps/NwaifuAnime/public/icons/icon-72x72.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
apps/NwaifuAnime/public/icons/icon-96x96.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
59
apps/NwaifuAnime/public/manifest.webmanifest
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "NwaifuAnime",
|
||||
"short_name": "NwaifuAnime",
|
||||
"theme_color": "#1976d2",
|
||||
"background_color": "#fafafa",
|
||||
"display": "standalone",
|
||||
"scope": "./",
|
||||
"start_url": "./",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icons/icon-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-128x128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-152x152.png",
|
||||
"sizes": "152x152",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
}
|
||||
]
|
||||
}
|
||||
14
apps/NwaifuAnime/src/app/app.component.html
Normal file
@@ -0,0 +1,14 @@
|
||||
@if (serviceWorkerEnabled) {
|
||||
@if (hasUpdate) {
|
||||
<h1>Update available</h1>
|
||||
<button (click)="update()">Update</button>
|
||||
} @else {
|
||||
<h1>Update not available</h1>
|
||||
}
|
||||
}
|
||||
<app-header></app-header>
|
||||
<div class="h-10"></div>
|
||||
<main>
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
<app-notification></app-notification>
|
||||
4
apps/NwaifuAnime/src/app/app.component.less
Normal file
@@ -0,0 +1,4 @@
|
||||
main {
|
||||
overflow-y: auto;
|
||||
height: calc(100vh - 3rem);
|
||||
}
|
||||
30
apps/NwaifuAnime/src/app/app.component.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Component } from "@angular/core";
|
||||
import { RouterModule } from "@angular/router";
|
||||
import { AppService } from "./app.service";
|
||||
import { HeaderComponent } from "./components/header/header.component";
|
||||
import { NotificationComponent } from "./components/notification/notification.component";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [RouterModule, HeaderComponent, NotificationComponent, NotificationComponent],
|
||||
selector: "app-root",
|
||||
templateUrl: "./app.component.html",
|
||||
styleUrl: "./app.component.less",
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppComponent {
|
||||
title = "NwaifuAnime";
|
||||
constructor(private sw: AppService) {}
|
||||
|
||||
get hasUpdate() {
|
||||
return this.sw.isUpdateAvailable;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.sw.update();
|
||||
}
|
||||
|
||||
get serviceWorkerEnabled() {
|
||||
return this.sw.serviceWorkerEnabled;
|
||||
}
|
||||
}
|
||||
22
apps/NwaifuAnime/src/app/app.config.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { provideHttpClient, withFetch } from "@angular/common/http";
|
||||
import { ApplicationConfig, isDevMode, provideZoneChangeDetection } from "@angular/core";
|
||||
import { provideRouter } from "@angular/router";
|
||||
import { provideServiceWorker } from "@angular/service-worker";
|
||||
import { appRoutes } from "./app.routes";
|
||||
import { Parser } from "./services/parsers/parser";
|
||||
import { MangalibParserService } from "./services/parsers/rulib/mangalib.parser.service";
|
||||
import { SlashlibParserService } from "./services/parsers/rulib/slashlib.parser.service";
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||
provideRouter(appRoutes),
|
||||
provideServiceWorker("ngsw-worker.js", {
|
||||
enabled: !isDevMode(),
|
||||
registrationStrategy: "registerWhenStable:30000",
|
||||
}),
|
||||
provideHttpClient(withFetch()),
|
||||
{ provide: Parser, multi: true, useClass: MangalibParserService },
|
||||
{ provide: Parser, multi: true, useClass: SlashlibParserService },
|
||||
],
|
||||
};
|
||||
18
apps/NwaifuAnime/src/app/app.routes.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Route } from "@angular/router";
|
||||
import { AuthComponent } from "./components/auth/auth.component";
|
||||
import { DetailComponent } from "./components/detail/detail.component";
|
||||
import { HomeComponent } from "./components/home/home.component";
|
||||
import { ReaderComponent } from "./components/reader/reader.component";
|
||||
|
||||
export const appRoutes: Route[] = [
|
||||
{
|
||||
path: "",
|
||||
component: HomeComponent,
|
||||
},
|
||||
{ path: "detail", component: DetailComponent },
|
||||
{ path: "reader", component: ReaderComponent },
|
||||
{
|
||||
path: "auth",
|
||||
component: AuthComponent,
|
||||
},
|
||||
];
|
||||
40
apps/NwaifuAnime/src/app/app.service.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { SwUpdate } from "@angular/service-worker";
|
||||
|
||||
@Injectable({ providedIn: "root" })
|
||||
export class AppService {
|
||||
private hasUpdate = false;
|
||||
constructor(private sw: SwUpdate) {
|
||||
if (this.sw.isEnabled) {
|
||||
console.log("service init");
|
||||
this.sw.checkForUpdate();
|
||||
|
||||
this.sw.versionUpdates.subscribe((ev) => {
|
||||
if (ev.type == "VERSION_DETECTED") {
|
||||
console.log("update detected");
|
||||
this.hasUpdate = true;
|
||||
} else {
|
||||
console.log("no update");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get isUpdateAvailable() {
|
||||
return this.hasUpdate;
|
||||
}
|
||||
|
||||
get serviceWorkerEnabled() {
|
||||
return this.sw.isEnabled;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.sw.activateUpdate().then((res) => {
|
||||
if (res) {
|
||||
console.log("updated");
|
||||
this.hasUpdate = false;
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
46
apps/NwaifuAnime/src/app/components/auth/auth.component.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<div class="flex flex-col m-6">
|
||||
<div class="mangalib-auth">
|
||||
<h2>Авторизация в MangaLib</h2>
|
||||
<ol class="list-decimal flex flex-col gap-4">
|
||||
<li>
|
||||
<p class="font-bold">Авторизация через токен</p>
|
||||
<div class="flex flex-row gap-4">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Token"
|
||||
class="outline-none border-md border px-2"
|
||||
#libSocialToken
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
(click)="setLibSocialToken()"
|
||||
class="hover:bg-slate-600 bg-slate-400 p-3 rounded-md text-white"
|
||||
>
|
||||
Сохранить
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
Вход через скрипт TamperMonkey. Если нет кнопки, значит вы не установили скрипт
|
||||
<a
|
||||
href="https://test-front.mangalib.me"
|
||||
class="hover:bg-slate-600 bg-slate-400 p-3 rounded-md text-white tamperMonkey"
|
||||
>
|
||||
Вход
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<div class="flex flex-row gap-3">
|
||||
<button
|
||||
type="button"
|
||||
(click)="checkToken()"
|
||||
class="hover:bg-slate-600 bg-slate-400 p-3 rounded-md text-white"
|
||||
>
|
||||
Проверить токен
|
||||
</button>
|
||||
<h3 class="self-center">{{ isRuLibAuth ? "Авторизован" : "Не авторизован" }}</h3>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
86
apps/NwaifuAnime/src/app/components/auth/auth.component.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
|
||||
import { ActivatedRoute, Router, RouterLink } from "@angular/router";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
import { NotificationService } from "../../services/notification/notification.service";
|
||||
import { RulibAuthService } from "../../services/parsers/rulib/rulib.auth.service";
|
||||
import { EAuthTokenService } from "./enum";
|
||||
|
||||
@Component({
|
||||
selector: "app-auth",
|
||||
templateUrl: "./auth.component.html",
|
||||
styleUrls: ["./auth.component.less"],
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterLink],
|
||||
})
|
||||
export class AuthComponent implements AfterViewInit, OnDestroy {
|
||||
private destroy$ = new Subject<void>();
|
||||
@ViewChild("libSocialToken") libSocialToken: ElementRef<HTMLInputElement> | null = null;
|
||||
isRuLibAuth = false;
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private rulibAuthService: RulibAuthService,
|
||||
private notificationService: NotificationService,
|
||||
) {}
|
||||
|
||||
private setToken(service: EAuthTokenService, token: string) {
|
||||
switch (service) {
|
||||
case EAuthTokenService.RULIB:
|
||||
this.rulibAuthService
|
||||
.setToken(token)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data) => {
|
||||
if (data) {
|
||||
this.router.navigate(["/"]);
|
||||
this.notificationService.info("Успешная авторизация в RuLib!", "Вход");
|
||||
} else {
|
||||
this.router.navigate(["/", "auth"]);
|
||||
this.notificationService.error(
|
||||
"Не удалось авторизоваться в RuLib! Попробуйте ещё раз.",
|
||||
"Вход",
|
||||
4000,
|
||||
);
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
this.router.navigate(["/", "auth"]);
|
||||
this.notificationService.error("Неизвестный сервис авторизации!", "Вход");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setLibSocialToken() {
|
||||
if (this.libSocialToken) {
|
||||
const token = this.libSocialToken.nativeElement.value;
|
||||
this.setToken(EAuthTokenService.RULIB, token);
|
||||
}
|
||||
}
|
||||
|
||||
checkToken() {
|
||||
this.rulibAuthService
|
||||
.checkToken(this.rulibAuthService.getToken())
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data) => {
|
||||
this.isRuLibAuth = data;
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||
const { token, service } = params;
|
||||
if (token && service) {
|
||||
this.setToken(service as EAuthTokenService, token);
|
||||
}
|
||||
});
|
||||
if (this.libSocialToken) {
|
||||
this.libSocialToken.nativeElement.value = this.rulibAuthService.getToken();
|
||||
}
|
||||
this.checkToken();
|
||||
}
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
3
apps/NwaifuAnime/src/app/components/auth/enum.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export enum EAuthTokenService {
|
||||
RULIB = "rulib",
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<div class="flex flex-col items-center">
|
||||
@if (needAuth) {
|
||||
<h1>Необходима авторизация</h1>
|
||||
<a routerLink="/auth" class="text-center bg-slate-600 text-white p-3 rounded-md mb-4">Войти</a>
|
||||
}
|
||||
@if (detail_item) {
|
||||
<h1>{{ detail_item.name }}</h1>
|
||||
<h2>{{ detail_item.rus_name }}</h2>
|
||||
<img [src]="detail_item.cover.default" [alt]="detail_item.slug" />
|
||||
|
||||
@if (!needAuth) {
|
||||
<details class="w-full">
|
||||
<summary class="text-center sticky top-0 bg-white z-10 py-2">
|
||||
<h3>Главы</h3>
|
||||
</summary>
|
||||
<div class="flex flex-col items-center pb-16">
|
||||
@for (chapter of chapters.data; track $index) {
|
||||
<a
|
||||
routerLink="/reader"
|
||||
[queryParams]="{
|
||||
url: detail_item.slug_url,
|
||||
chapter: chapter.number,
|
||||
volume: chapter.volume,
|
||||
}"
|
||||
[title]="chapter.name"
|
||||
class="p-3 text-white bg-slate-600 w-[300px] mt-3 rounded-lg"
|
||||
>
|
||||
<h3>
|
||||
<strong>{{ chapter.number }}.</strong> {{ chapter.name || "Нет названия" }}
|
||||
</h3>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</details>
|
||||
<a
|
||||
routerLink="/reader"
|
||||
class="p-3 text-white bg-slate-600 w-[300px] mt-5 rounded-lg text-center"
|
||||
[queryParams]="{ url: detail_item.slug_url, volume: 1, chapter: 1 }"
|
||||
>
|
||||
Читать
|
||||
</a>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,71 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component, OnDestroy } from "@angular/core";
|
||||
import { ActivatedRoute, Router, RouterLink } from "@angular/router";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
import { IRulibChaptersResult } from "../../services/parsers/rulib/rulib.chapters.dto";
|
||||
import { Data } from "../../services/parsers/rulib/rulib.detail.dto";
|
||||
import { SearchService } from "../../services/search.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-detail",
|
||||
templateUrl: "./detail.component.html",
|
||||
styleUrls: ["./detail.component.less"],
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterLink],
|
||||
})
|
||||
export class DetailComponent implements AfterViewInit, OnDestroy {
|
||||
detail_item: Data | null = null;
|
||||
chapters: IRulibChaptersResult = { data: [] };
|
||||
needAuth: boolean = false;
|
||||
private destroy$ = new Subject<void>();
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private searchService: SearchService,
|
||||
private router: Router,
|
||||
) {}
|
||||
|
||||
private getDetails(url: string) {
|
||||
this.searchService
|
||||
.getDetails(url)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
this.detail_item = data.data;
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
},
|
||||
});
|
||||
this.searchService
|
||||
.getChapters(url)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
this.chapters = data;
|
||||
if (data.data.length === 0) {
|
||||
this.needAuth = true;
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||
const url = params["url"];
|
||||
if (url) {
|
||||
this.searchService.setMangalibParser();
|
||||
this.getDetails(url);
|
||||
} else {
|
||||
this.router.navigate(["/"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<div
|
||||
[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 h-8 items-center">
|
||||
<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>
|
||||
@@ -0,0 +1,3 @@
|
||||
.header {
|
||||
transition: height 0.3s;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
|
||||
import { ActivatedRoute, NavigationEnd, Router, RouterLink } from "@angular/router";
|
||||
import { Subject, filter, takeUntil } from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: "app-header",
|
||||
templateUrl: "./header.component.html",
|
||||
styleUrls: ["./header.component.less"],
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterLink],
|
||||
})
|
||||
export class HeaderComponent implements AfterViewInit, OnDestroy {
|
||||
@ViewChild("searchInput") searchInput: ElementRef<HTMLInputElement> | null = null;
|
||||
menuOpened = false;
|
||||
private destroy$ = new Subject<void>();
|
||||
constructor(
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
) {
|
||||
this.router.events
|
||||
.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 {
|
||||
return `lni ${this.menuOpened ? "lni-close" : "lni-menu"} text-white`;
|
||||
}
|
||||
|
||||
get searchBarClass(): string {
|
||||
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() {
|
||||
if (this.searchInput) {
|
||||
const text = this.searchInput.nativeElement.value;
|
||||
this.router.navigateByUrl(`/?search=${text}`);
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||
const search = params["search"];
|
||||
if (search && this.searchInput) {
|
||||
this.searchInput.nativeElement.value = search;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
30
apps/NwaifuAnime/src/app/components/home/home.component.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<h1>It's home component</h1>
|
||||
@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) {
|
||||
<h1>Loading...</h1>
|
||||
}
|
||||
@if (notFound && !loading) {
|
||||
<h1>Not found</h1>
|
||||
}
|
||||
@for (item of items; track $index) {
|
||||
<a
|
||||
routerLink="/detail"
|
||||
[queryParams]="{ url: item.slug_url }"
|
||||
title="{{ item.name }}"
|
||||
class="mb-6 max-w-[700px] w-full"
|
||||
>
|
||||
<div class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full">
|
||||
<h1>{{ item.rus_name }}</h1>
|
||||
<img [src]="item.cover.thumbnail" [alt]="item.slug" class="w-[200px] h-auto aspect-auto" />
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
90
apps/NwaifuAnime/src/app/components/home/home.component.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, Input, OnDestroy, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, RouterLink } from "@angular/router";
|
||||
import { map, Subject, Subscription, takeUntil } from "rxjs";
|
||||
import { IRuLIBPopular } from "../../services/parsers/rulib/rulib.popular.dto";
|
||||
import { Datum } from "../../services/parsers/rulib/rulib.search.dto";
|
||||
import { SearchService } from "../../services/search.service";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: "app-home",
|
||||
templateUrl: "./home.component.html",
|
||||
styleUrls: ["./home.component.less"],
|
||||
imports: [CommonModule, RouterLink],
|
||||
})
|
||||
export class HomeComponent implements OnDestroy, OnInit {
|
||||
@Input() items: Datum[] = [];
|
||||
loading = false;
|
||||
notFound = false;
|
||||
search: string = "";
|
||||
popularItemsMap: Map<string, IRuLIBPopular[]> = new Map<string, IRuLIBPopular[]>();
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private popularSubscription = new Subscription();
|
||||
|
||||
constructor(
|
||||
private searchService: SearchService,
|
||||
private route: ActivatedRoute,
|
||||
) {
|
||||
this.searchService.setMangalibParser();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
this.popularSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
private getPopular() {
|
||||
if (!this.popularSubscription.closed) this.popularSubscription.unsubscribe();
|
||||
this.popularSubscription = this.searchService
|
||||
.getPopular()
|
||||
.pipe(map((data) => data as IRuLIBPopular[]))
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
this.popularItemsMap.set(this.searchService.getRuLibName(), data);
|
||||
console.log(this.popularItemsMap);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getPopularMangalib() {
|
||||
this.searchService.setMangalibParser();
|
||||
this.getPopular();
|
||||
}
|
||||
|
||||
getPopularSlashlib() {
|
||||
this.searchService.setSlashlibParser();
|
||||
this.getPopular();
|
||||
}
|
||||
|
||||
get popularItems() {
|
||||
return this.popularItemsMap.entries();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||
this.search = params["search"] ?? "";
|
||||
this.items = [];
|
||||
if (this.search) {
|
||||
this.loading = true;
|
||||
this.searchService.setMangalibParser();
|
||||
this.searchService
|
||||
.search(this.search)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data) => {
|
||||
this.loading = false;
|
||||
this.items = data.data;
|
||||
this.notFound = this.items.length === 0;
|
||||
});
|
||||
} else {
|
||||
this.getPopularMangalib();
|
||||
this.getPopularSlashlib();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<div
|
||||
class="notification-container fixed md:right-0 bottom-0 max-w-[100%] min-w-[100%] min-h-[8rem] h-[8rem] md:min-w-[20rem] px-3 pb-4"
|
||||
[hidden]="!show_notification"
|
||||
>
|
||||
<div [class]="'notification rounded-md bg-white border-2 ' + borderColor + ' h-full'">
|
||||
<div [class]="'head flex flex-row justify-between px-2 py-2 h-5 border-b-2 ' + borderColor">
|
||||
<h3 class="self-center">{{ notification.name }}</h3>
|
||||
<button class="self-center" (click)="closeNotification()" type="button">X</button>
|
||||
</div>
|
||||
<div class="notification-text mx-3 my-1">{{ notification.message }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,53 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component, OnDestroy } from "@angular/core";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
import { INotification } from "../../services/notification/notification.dto";
|
||||
import { NotificationService } from "../../services/notification/notification.service";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: "app-notification",
|
||||
templateUrl: "./notification.component.html",
|
||||
styleUrls: ["./notification.component.less"],
|
||||
imports: [CommonModule],
|
||||
})
|
||||
export class NotificationComponent implements AfterViewInit, OnDestroy {
|
||||
show_notification = false;
|
||||
isError = false;
|
||||
private closeNotificationTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
notification: INotification = { isError: false, message: "", name: "", time: 0 };
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(private notificationService: NotificationService) {}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.notificationService.notification$
|
||||
.asObservable()
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data) => {
|
||||
if (!data) return;
|
||||
this.notification = data;
|
||||
this.show_notification = true;
|
||||
if (this.closeNotificationTimer) {
|
||||
clearTimeout(this.closeNotificationTimer);
|
||||
}
|
||||
this.closeNotificationTimer = setTimeout(() => {
|
||||
this.show_notification = false;
|
||||
}, data.time);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
closeNotification() {
|
||||
this.show_notification = false;
|
||||
}
|
||||
|
||||
get borderColor(): string {
|
||||
return this.notification.isError ? "border-red-600" : "border-green-600";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<div
|
||||
class="flex flex-row items-center justify-between me-4 max-w-[900px] relative -translate-x-[50%] left-[50%]"
|
||||
>
|
||||
<a
|
||||
[routerLink]="['/', 'detail']"
|
||||
[queryParams]="{ url: url }"
|
||||
class="bg-slate-600 text-white rounded-lg p-3 m-4"
|
||||
>
|
||||
Назад к тайтлу
|
||||
</a>
|
||||
<h3>{{ currentChapterInfo?.number }}. {{ currentChapterInfo?.name || "Нет названия" }}</h3>
|
||||
</div>
|
||||
<div class="flex flex-col items-center">
|
||||
@if (pages.length > 0 && currentPage) {
|
||||
<div [class]="imageContainerClass">
|
||||
@if (!isManhwa) {
|
||||
<app-scale-image [imageSrc]="currentPage.imageUrl"></app-scale-image>
|
||||
} @else {
|
||||
@for (page of manhwaPages; track page.id) {
|
||||
<app-scale-image
|
||||
[imageSrc]="page.imageUrl"
|
||||
[host]="host"
|
||||
(view)="loadPage(page.index)"
|
||||
[hostScrollable]="isHostScrollable()"
|
||||
></app-scale-image>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="flex items-center justify-center space-x-4 my-10">
|
||||
<button (click)="prevPage()" class="p-3 text-white bg-slate-600 w-[100px] rounded-lg">
|
||||
←
|
||||
</button>
|
||||
<p *ngIf="!isManhwa">{{ pages[currentPageIndex].slug }} / {{ pages.length }}</p>
|
||||
<button (click)="nextPage()" class="p-3 text-white bg-slate-600 w-[100px] rounded-lg">
|
||||
→
|
||||
</button>
|
||||
</div>
|
||||
<div class="hidden md:block md:fixed right-10 top-[50%]">
|
||||
{{ currentPageIndex + 1 }} / {{ pages.length }}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
:host {
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
245
apps/NwaifuAnime/src/app/components/reader/reader.component.ts
Normal file
@@ -0,0 +1,245 @@
|
||||
import { CommonModule, isPlatformBrowser } from "@angular/common";
|
||||
import {
|
||||
Component,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
Inject,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
PLATFORM_ID,
|
||||
} from "@angular/core";
|
||||
import { ActivatedRoute, Router, RouterLink } from "@angular/router";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
import { Chapter, Page } from "../../services/parsers/rulib/rulib.chapter.dto";
|
||||
import { IRulibChapter } from "../../services/parsers/rulib/rulib.chapters.dto";
|
||||
import { SearchService } from "../../services/search.service";
|
||||
import { ScaleImageComponent } from "../scale-image/scale-image.component";
|
||||
import { CachedPage, CachedPages } from "./reader.dto";
|
||||
|
||||
@Component({
|
||||
selector: "app-reader",
|
||||
templateUrl: "./reader.component.html",
|
||||
styleUrls: ["./reader.component.less"],
|
||||
standalone: true,
|
||||
imports: [CommonModule, ScaleImageComponent, RouterLink],
|
||||
})
|
||||
export class ReaderComponent implements OnInit, OnDestroy {
|
||||
pages: Page[] = [];
|
||||
currentPageIndex = 0;
|
||||
cachedPages: CachedPages = new Map<number, CachedPage>();
|
||||
imageUrl: string = "";
|
||||
isManhwa = false;
|
||||
currentChapterInfo: Chapter | null = null;
|
||||
url = "";
|
||||
private chaptersInfo: IRulibChapter[] = [];
|
||||
private chapterNum: number = 0;
|
||||
private chapterVol: number = 0;
|
||||
private fromTowards = false;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private searchService: SearchService,
|
||||
public host: ElementRef,
|
||||
@Inject(PLATFORM_ID) private platformId: object,
|
||||
) {}
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
get manhwaPages() {
|
||||
return this.cachedPages.values();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||
const url = params["url"];
|
||||
const chapter = params["chapter"];
|
||||
const volume = params["volume"];
|
||||
const fromTowards = params["from_towards"];
|
||||
if (url && chapter && volume) {
|
||||
this.searchService.setMangalibParser();
|
||||
if (fromTowards) this.fromTowards = Boolean(+fromTowards);
|
||||
else this.fromTowards = false;
|
||||
this.chapterNum = +chapter;
|
||||
this.chapterVol = +volume;
|
||||
this.url = url;
|
||||
this.searchService
|
||||
.getChapters(url)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data) => {
|
||||
this.chaptersInfo = data.data;
|
||||
});
|
||||
this.searchService
|
||||
.isManhwa(url)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data) => {
|
||||
this.isManhwa = data;
|
||||
this.loadChapter(url, chapter, volume);
|
||||
});
|
||||
} else {
|
||||
this.router.navigate(["/"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public isHostScrollable(): boolean {
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
const style = window.getComputedStyle(this.host.nativeElement);
|
||||
return (
|
||||
style.getPropertyValue("overflow") === "auto" ||
|
||||
style.getPropertyValue("overflow-y") === "scroll"
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
backToTitle() {
|
||||
this.router.navigate(["/", "detail"], { queryParams: { url: this.url } });
|
||||
}
|
||||
|
||||
loadChapter(url: string, chapter: string, volume: string) {
|
||||
this.searchService
|
||||
.getChapter(url, chapter, volume)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
this.currentChapterInfo = data.data;
|
||||
this.pages = data.data.pages;
|
||||
this.pages.forEach((page, index) => {
|
||||
this.cachedPages.set(index, {
|
||||
...page,
|
||||
imageUrl: "",
|
||||
isManhwa: this.isManhwa,
|
||||
index,
|
||||
});
|
||||
});
|
||||
this.loadPage(0);
|
||||
if (this.fromTowards) {
|
||||
this.currentPageIndex = this.pages.length - 1;
|
||||
this.loadPage(this.pages.length - 1); // Загрузить последнюю страницу при открытии главы
|
||||
} else this.loadPage(0); // Загрузить первую страницу при открытии главы
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
this.router.navigate(["/", "detail"], { queryParams: { url: this.url } });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public intersectionLoadPage(id: number) {
|
||||
const data = Array.from(this.cachedPages.values()).find((page) => page.id === id)!;
|
||||
this.fetchPage(data);
|
||||
}
|
||||
|
||||
private loadPageByIndex(index: number) {
|
||||
const data = this.cachedPages.get(index)!;
|
||||
this.fetchPage(data);
|
||||
}
|
||||
|
||||
get currentPage() {
|
||||
return this.cachedPages.get(this.currentPageIndex);
|
||||
}
|
||||
|
||||
private fetchPage(page: CachedPage) {
|
||||
if (!page.imageUrl)
|
||||
this.searchService
|
||||
.getImageData(this.searchService.getImageServer() + page.url)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data) => {
|
||||
const url = this.getImageUrl(data);
|
||||
this.cachedPages.set(page.index, {
|
||||
...page,
|
||||
imageUrl: url,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private cachePage(index: number) {
|
||||
for (let i = index; i < Math.min(index + 2, this.cachedPages.size); i++) {
|
||||
this.loadPageByIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
private clearCache(index: number) {
|
||||
for (let i = 0; i <= index; i++) {
|
||||
const imgUrl = this.cachedPages.get(i)!.imageUrl;
|
||||
this.cachedPages.get(i)!.imageUrl = "";
|
||||
URL.revokeObjectURL(imgUrl);
|
||||
}
|
||||
}
|
||||
|
||||
loadPage(index: number) {
|
||||
if (index >= 0 && index < this.pages.length) {
|
||||
this.currentPageIndex = index;
|
||||
this.cachePage(index);
|
||||
this.clearCache(index - 2);
|
||||
} else if (index == this.cachedPages.size) {
|
||||
const thisChapterIndex = this.chaptersInfo.findIndex((chapter) => {
|
||||
return +chapter.number === this.chapterNum && +chapter.volume === this.chapterVol;
|
||||
});
|
||||
const nextChapterIndex = Math.min(thisChapterIndex + 1, this.chaptersInfo.length - 1);
|
||||
const nextChapter = this.chaptersInfo[nextChapterIndex];
|
||||
if (nextChapter !== this.chaptersInfo[thisChapterIndex]) {
|
||||
this.cachedPages.clear();
|
||||
this.router.navigate(["/", "reader"], {
|
||||
queryParams: {
|
||||
url: this.url,
|
||||
chapter: nextChapter.number,
|
||||
volume: nextChapter.volume,
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (index == -1) {
|
||||
const thisChapterIndex = this.chaptersInfo.findIndex((chapter) => {
|
||||
return +chapter.number === this.chapterNum && +chapter.volume === this.chapterVol;
|
||||
});
|
||||
const prevChapterIndex = Math.max(thisChapterIndex - 1, 0);
|
||||
const prevChapter = this.chaptersInfo[prevChapterIndex];
|
||||
if (prevChapter !== this.chaptersInfo[thisChapterIndex]) {
|
||||
this.cachedPages.clear();
|
||||
this.router.navigate(["/", "reader"], {
|
||||
queryParams: {
|
||||
url: this.url,
|
||||
chapter: prevChapter.number,
|
||||
volume: prevChapter.volume,
|
||||
from_towards: 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener("window:keydown", ["$event"])
|
||||
onKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "ArrowRight") {
|
||||
this.nextPage();
|
||||
} else if (event.key === "ArrowLeft") {
|
||||
this.prevPage();
|
||||
}
|
||||
}
|
||||
|
||||
private getImageUrl(imageData?: Uint8Array): string {
|
||||
if (!imageData) {
|
||||
return "";
|
||||
}
|
||||
const blob = new Blob([imageData], { type: "image/jpeg" });
|
||||
const urlCreator = window.URL || window.webkitURL;
|
||||
return urlCreator.createObjectURL(blob);
|
||||
}
|
||||
|
||||
nextPage() {
|
||||
this.loadPage(this.currentPageIndex + 1);
|
||||
}
|
||||
|
||||
prevPage() {
|
||||
this.loadPage(this.currentPageIndex - 1);
|
||||
}
|
||||
|
||||
get imageContainerClass() {
|
||||
return `${this.isManhwa ? "h-auto" : "h-[70vh]"} w-[95vw] md:w-[450px] flex flex-col`;
|
||||
}
|
||||
}
|
||||
10
apps/NwaifuAnime/src/app/components/reader/reader.dto.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Page } from "../../services/parsers/rulib/rulib.chapter.dto";
|
||||
|
||||
export interface CachedPage extends Page {
|
||||
imageData?: Uint8Array;
|
||||
imageUrl: string;
|
||||
index: number;
|
||||
isManhwa: boolean;
|
||||
}
|
||||
|
||||
export type CachedPages = Map<number, CachedPage>;
|
||||
@@ -0,0 +1,7 @@
|
||||
<div class="image-container" #container>
|
||||
@if (imageSrc) {
|
||||
<img #image [src]="imageSrc" (load)="onImageLoad()" alt="Manga page" />
|
||||
} @else {
|
||||
<div class="h-screen flex flex-col items-center justify-center"><h1>Loading...</h1></div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
.image-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import {
|
||||
AfterViewInit,
|
||||
Component,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnDestroy,
|
||||
Output,
|
||||
ViewChild,
|
||||
} from "@angular/core";
|
||||
import { Subscription, debounceTime, fromEvent } from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: "app-scale-image",
|
||||
templateUrl: "./scale-image.component.html",
|
||||
styleUrls: ["./scale-image.component.less"],
|
||||
standalone: true,
|
||||
})
|
||||
export class ScaleImageComponent implements AfterViewInit, OnDestroy {
|
||||
@Input({ required: true }) imageSrc: string = "";
|
||||
@ViewChild("container", { static: true }) containerRef: ElementRef | null = null;
|
||||
@ViewChild("image", { static: true }) imageRef: ElementRef | null = null;
|
||||
@Output() view = new EventEmitter<void>();
|
||||
@Input() host: ElementRef | null = null;
|
||||
@Input() hostScrollable: boolean = false;
|
||||
|
||||
private resizeSubscription: Subscription = new Subscription();
|
||||
private observer!: IntersectionObserver;
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.setupResizeListener();
|
||||
if (this.host) {
|
||||
this.observer = new IntersectionObserver(
|
||||
([entry]) => entry.isIntersecting && this.view.emit(),
|
||||
{
|
||||
root: this.hostScrollable ? this.host.nativeElement : null,
|
||||
rootMargin: "100px",
|
||||
},
|
||||
);
|
||||
if (this.containerRef) this.observer.observe(this.containerRef.nativeElement);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.resizeSubscription) this.resizeSubscription.unsubscribe();
|
||||
if (this.observer) this.observer.disconnect();
|
||||
}
|
||||
|
||||
onImageLoad() {
|
||||
this.scaleImage();
|
||||
}
|
||||
|
||||
private setupResizeListener() {
|
||||
this.resizeSubscription = fromEvent(window, "resize")
|
||||
.pipe(debounceTime(200))
|
||||
.subscribe(() => this.scaleImage());
|
||||
}
|
||||
|
||||
private scaleImage() {
|
||||
if (this.containerRef && this.imageRef) {
|
||||
const container = this.containerRef.nativeElement;
|
||||
const img = this.imageRef.nativeElement;
|
||||
|
||||
const containerWidth = container.clientWidth;
|
||||
const containerHeight = container.clientHeight;
|
||||
const imgRatio = img.naturalWidth / img.naturalHeight;
|
||||
const containerRatio = containerWidth / containerHeight;
|
||||
|
||||
let newWidth, newHeight;
|
||||
|
||||
if (imgRatio > containerRatio) {
|
||||
newWidth = containerWidth;
|
||||
newHeight = containerWidth / imgRatio;
|
||||
} else {
|
||||
newHeight = containerHeight;
|
||||
newWidth = containerHeight * imgRatio;
|
||||
}
|
||||
|
||||
newWidth = Math.min(newWidth, img.naturalWidth);
|
||||
newHeight = Math.min(newHeight, img.naturalHeight);
|
||||
|
||||
if (img.naturalHeight / img.naturalWidth >= 5) {
|
||||
img.style.width = "100%";
|
||||
img.style.height = "auto";
|
||||
} else {
|
||||
img.style.width = `${newWidth}px`;
|
||||
img.style.height = `${newHeight}px`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface INotification {
|
||||
message: string;
|
||||
isError: boolean;
|
||||
time: number;
|
||||
name: string;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Injectable, OnDestroy } from "@angular/core";
|
||||
import { Subject } from "rxjs";
|
||||
import { INotification } from "./notification.dto";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class NotificationService implements OnDestroy {
|
||||
readonly notification$ = new Subject<INotification>();
|
||||
|
||||
private sendNotification(message: INotification) {
|
||||
this.notification$.next(message);
|
||||
}
|
||||
|
||||
info(message: string, title: string = "", time = 3000) {
|
||||
this.sendNotification({
|
||||
message,
|
||||
isError: false,
|
||||
time: time,
|
||||
name: title,
|
||||
});
|
||||
}
|
||||
|
||||
error(message: string, title: string = "", time = 3000) {
|
||||
this.sendNotification({
|
||||
message,
|
||||
isError: true,
|
||||
time: time,
|
||||
name: title,
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.notification$.complete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
export function ParserDecorator({
|
||||
site_name,
|
||||
url,
|
||||
nsfw = false,
|
||||
site_id = 1,
|
||||
}: {
|
||||
site_name: string;
|
||||
url: string;
|
||||
nsfw?: boolean;
|
||||
site_id?: number;
|
||||
}) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
return function (constructor: Function) {
|
||||
constructor.prototype.site_name = site_name;
|
||||
constructor.prototype.nsfw = nsfw;
|
||||
constructor.prototype.api_url = url;
|
||||
constructor.prototype.site_id = site_id;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export enum EParser {
|
||||
MangaLib = 0,
|
||||
SlashLib = 1,
|
||||
}
|
||||
20
apps/NwaifuAnime/src/app/services/parsers/parser.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
@Injectable({ providedIn: "root" })
|
||||
export abstract class Parser {
|
||||
constructor(protected http: HttpClient) {}
|
||||
|
||||
protected abstract url: string;
|
||||
|
||||
abstract searchManga(query: string): Observable<object>;
|
||||
|
||||
abstract getDetails(slug_url: string): Observable<object>;
|
||||
|
||||
abstract getChapters(url: string): Observable<object>;
|
||||
|
||||
abstract getChapter(url: string, chapter: string, volume: string): Observable<object>;
|
||||
|
||||
abstract getPopular(): Observable<object[]>;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Observable, catchError, map, throwError } from "rxjs";
|
||||
import { Parser } from "../parser";
|
||||
import { RulibAuthService } from "./rulib.auth.service";
|
||||
import { IRulibChapterResult } from "./rulib.chapter.dto";
|
||||
import { IRulibChaptersResult } from "./rulib.chapters.dto";
|
||||
import { IRulibDetailResult } from "./rulib.detail.dto";
|
||||
import { IRuLIBPopular } from "./rulib.popular.dto";
|
||||
import { IRulibSearchResult } from "./rulib.search.dto";
|
||||
|
||||
//TODO: Make abstract classes
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class LibSocialParserService extends Parser {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
protected url = (this as any).api_url;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
private site_id = (this as any).site_id;
|
||||
get imageServer() {
|
||||
return "https://img33.imgslib.link";
|
||||
}
|
||||
|
||||
constructor(
|
||||
private rulibAuthService: RulibAuthService,
|
||||
override http: HttpClient,
|
||||
) {
|
||||
super(http);
|
||||
}
|
||||
|
||||
searchManga(query: string): Observable<IRulibSearchResult> {
|
||||
return this.http
|
||||
.get(
|
||||
`${this.url}/api/manga?fields[]=rate_avg&fields[]=rate&q=${query}&site_id[]=${this.site_id}`,
|
||||
)
|
||||
.pipe(
|
||||
map((data: object) => {
|
||||
return data as IRulibSearchResult;
|
||||
}),
|
||||
catchError((error) => {
|
||||
return throwError(() => `Now found ${error}`);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getDetails(slug_url: string): Observable<IRulibDetailResult> {
|
||||
return this.http
|
||||
.get(
|
||||
`${this.url}/api/manga/${slug_url}?fields[]=summary&fields[]=genres&fields[]=tags&fields[]=authors`,
|
||||
{ headers: { Authorization: "Bearer " + this.rulibAuthService.getToken() } },
|
||||
)
|
||||
.pipe(
|
||||
map((data: object) => {
|
||||
return data as IRulibDetailResult;
|
||||
}),
|
||||
catchError((error) => {
|
||||
return throwError(() => `Now found ${error}`);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getChapters(url: string): Observable<IRulibChaptersResult> {
|
||||
return this.http
|
||||
.get(`${this.url}/api/manga/${url}/chapters`, {
|
||||
headers: { Authorization: "Bearer " + this.rulibAuthService.getToken() },
|
||||
})
|
||||
.pipe(
|
||||
map((data) => {
|
||||
return data as IRulibChaptersResult;
|
||||
}),
|
||||
catchError((error) => {
|
||||
return throwError(() => `Now found ${error}`);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getChapter(url: string, chapter: string, volume: string): Observable<IRulibChapterResult> {
|
||||
return this.http
|
||||
.get(`${this.url}/api/manga/${url}/chapter?number=${chapter}&volume=${volume}`, {
|
||||
headers: { Authorization: "Bearer " + this.rulibAuthService.getToken() },
|
||||
})
|
||||
.pipe(
|
||||
map((data) => data as IRulibChapterResult),
|
||||
catchError((error) => throwError(() => `Now found ${error}`)),
|
||||
);
|
||||
}
|
||||
|
||||
isManhwa(slug_url: string): Observable<boolean> {
|
||||
return this.http
|
||||
.get(
|
||||
`${this.url}/api/manga/${slug_url}?fields[]=summary&fields[]=genres&fields[]=tags&fields[]=authors`,
|
||||
)
|
||||
.pipe(
|
||||
map((data) => {
|
||||
const res = data as IRulibDetailResult;
|
||||
return [5, 6, 4].includes(res.data.type.id);
|
||||
}),
|
||||
catchError((error) => throwError(() => `Now found ${error}`)),
|
||||
);
|
||||
}
|
||||
|
||||
getPopular(): Observable<IRuLIBPopular[]> {
|
||||
//TODO: мб сделать ассинхрон
|
||||
return this.http
|
||||
.get<{ data: { popular: [] } }>(`${this.url}/api/`, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + this.rulibAuthService.getToken(),
|
||||
"Site-Id": this.site_id,
|
||||
},
|
||||
})
|
||||
.pipe(
|
||||
map((data) => {
|
||||
const res = data.data.popular as IRuLIBPopular[];
|
||||
console.log(res);
|
||||
return res;
|
||||
}),
|
||||
catchError((error) => throwError(() => `Now found ${error}`)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { ParserDecorator } from "../decorators/parser.decorator";
|
||||
import { ESiteUrls } from "../urls";
|
||||
import { LibSocialParserService } from "./lib.social.parser.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
@ParserDecorator({ site_name: "MangaLib", url: ESiteUrls.MANGALIB, site_id: 1 })
|
||||
export class MangalibParserService extends LibSocialParserService {}
|
||||
@@ -0,0 +1,47 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Injectable, OnDestroy } from "@angular/core";
|
||||
import { Observable, Subject, catchError, map, of, takeUntil } from "rxjs";
|
||||
import { IToken } from "../token.dto";
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class RulibAuthService implements OnDestroy {
|
||||
private destroy$ = new Subject<void>();
|
||||
private api_url = "https://api.lib.social";
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
setToken(token: string): Observable<boolean> {
|
||||
return this.checkToken(token).pipe(
|
||||
takeUntil(this.destroy$),
|
||||
map((data) => {
|
||||
if (!data) return false;
|
||||
const token_data: IToken = JSON.parse(localStorage.getItem("token") ?? "{}");
|
||||
token_data.rulib_token = token;
|
||||
localStorage.setItem("token", JSON.stringify(token_data));
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getToken(): string {
|
||||
const token_data: IToken = JSON.parse(localStorage.getItem("token") ?? "{}");
|
||||
return token_data.rulib_token ?? "";
|
||||
}
|
||||
|
||||
checkToken(token: string): Observable<boolean> {
|
||||
return this.http
|
||||
.get(this.api_url + "/api/auth/me", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
map(() => true),
|
||||
catchError(() => of(false)),
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
export interface IRulibChapterResult {
|
||||
data: Chapter;
|
||||
}
|
||||
|
||||
export interface Chapter {
|
||||
id: number;
|
||||
type: string;
|
||||
volume: string;
|
||||
number: string;
|
||||
number_secondary: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
branch_id: null;
|
||||
manga_id: number;
|
||||
created_at: Date;
|
||||
moderated: Moderated;
|
||||
likes_count: number;
|
||||
teams: Team[];
|
||||
pages: Page[];
|
||||
}
|
||||
|
||||
export interface Moderated {
|
||||
id: number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface Page {
|
||||
id: number;
|
||||
image: string;
|
||||
slug: number;
|
||||
external: number;
|
||||
chunks: number;
|
||||
chapter_id: number;
|
||||
created_at: Date;
|
||||
updated_at: UpdatedAt;
|
||||
height: number;
|
||||
width: number;
|
||||
url: string;
|
||||
ratio: string;
|
||||
}
|
||||
|
||||
export enum UpdatedAt {
|
||||
The0000011130T000000000000Z = "-000001-11-30T00:00:00.000000Z",
|
||||
}
|
||||
|
||||
export interface Team {
|
||||
id: number;
|
||||
slug: string;
|
||||
slug_url: string;
|
||||
model: string;
|
||||
name: string;
|
||||
cover: Cover;
|
||||
vk: null;
|
||||
discord: null;
|
||||
}
|
||||
|
||||
export interface Cover {
|
||||
filename: null;
|
||||
thumbnail: string;
|
||||
default: string;
|
||||
md: string;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
export interface IRulibChaptersResult {
|
||||
data: IRulibChapter[];
|
||||
}
|
||||
|
||||
export interface IRulibChapter {
|
||||
id: number;
|
||||
index: number;
|
||||
item_number: number;
|
||||
volume: string;
|
||||
number: string;
|
||||
number_secondary: string;
|
||||
name: string;
|
||||
branches_count: number;
|
||||
branches: Branch[];
|
||||
}
|
||||
|
||||
export interface Branch {
|
||||
id: number;
|
||||
branch_id: null;
|
||||
created_at: Date;
|
||||
teams: Team[];
|
||||
user: User;
|
||||
}
|
||||
|
||||
export interface Team {
|
||||
id: number;
|
||||
slug: Slug;
|
||||
slug_url: SlugURL;
|
||||
model: Model;
|
||||
name: Name;
|
||||
cover: Cover;
|
||||
}
|
||||
|
||||
export interface Cover {
|
||||
filename: null | string;
|
||||
thumbnail: Thumbnail;
|
||||
default: Default;
|
||||
md: Default;
|
||||
}
|
||||
|
||||
export enum Default {
|
||||
StaticImagesPlaceholdersUserAvatarPNG = "/static/images/placeholders/user_avatar.png",
|
||||
UploadsTeamAnyasyavaCoverJSazXO7JdAKV250X350Jpg = "/uploads/team/anyasyava/cover/jSazXO7JdAKV_250x350.jpg",
|
||||
}
|
||||
|
||||
export enum Thumbnail {
|
||||
StaticImagesPlaceholdersUserAvatarPNG = "/static/images/placeholders/user_avatar.png",
|
||||
UploadsTeamAnyasyavaCoverJSazXO7JdAKVThumbJpg = "/uploads/team/anyasyava/cover/jSazXO7JdAKV_thumb.jpg",
|
||||
}
|
||||
|
||||
export enum Model {
|
||||
Team = "team",
|
||||
}
|
||||
|
||||
export enum Name {
|
||||
Abame = "abame",
|
||||
Anyasyava = "ANYASYAVA",
|
||||
Cabel = "Cabel",
|
||||
Deadvm = "deadvm",
|
||||
}
|
||||
|
||||
export enum Slug {
|
||||
Abame = "abame",
|
||||
Anyasyava = "anyasyava",
|
||||
Cabel = "cabel",
|
||||
Deadvm = "deadvm",
|
||||
}
|
||||
|
||||
export enum SlugURL {
|
||||
The13801Anyasyava = "13801--anyasyava",
|
||||
The33106Abame = "33106--abame",
|
||||
The42374Cabel = "42374--cabel",
|
||||
The45635Deadvm = "45635--deadvm",
|
||||
}
|
||||
|
||||
export interface User {
|
||||
username: Username;
|
||||
id: number;
|
||||
}
|
||||
|
||||
export enum Username {
|
||||
Deadvm = "deadvm",
|
||||
Gjunyaa = "gjunyaa ❤️\ud83e\ude79",
|
||||
Oksas = "oksas",
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
export interface IRulibDetailResult {
|
||||
data: Data;
|
||||
meta: Meta;
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
id: number;
|
||||
name: string;
|
||||
rus_name: string;
|
||||
eng_name: string;
|
||||
slug: string;
|
||||
slug_url: string;
|
||||
cover: Cover;
|
||||
ageRestriction: AgeRestriction;
|
||||
site: number;
|
||||
type: AgeRestriction;
|
||||
summary: string;
|
||||
is_licensed: boolean;
|
||||
genres: Genre[];
|
||||
tags: Genre[];
|
||||
authors: Author[];
|
||||
model: string;
|
||||
status: AgeRestriction;
|
||||
releaseDateString: string;
|
||||
}
|
||||
|
||||
export interface AgeRestriction {
|
||||
id: number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface Author {
|
||||
id: number;
|
||||
slug: string;
|
||||
slug_url: string;
|
||||
model: string;
|
||||
name: string;
|
||||
rus_name: null;
|
||||
alt_name: null;
|
||||
cover: Cover;
|
||||
subscription: Subscription;
|
||||
confirmed: null;
|
||||
user_id: number;
|
||||
}
|
||||
|
||||
export interface Cover {
|
||||
filename: null | string;
|
||||
thumbnail: string;
|
||||
default: string;
|
||||
md: string;
|
||||
}
|
||||
|
||||
export interface Subscription {
|
||||
is_subscribed: boolean;
|
||||
source_type: string;
|
||||
source_id: number;
|
||||
relation: null;
|
||||
}
|
||||
|
||||
export interface Genre {
|
||||
id: number;
|
||||
name: string;
|
||||
adult: boolean;
|
||||
alert: boolean;
|
||||
}
|
||||
|
||||
export interface Meta {
|
||||
country: string;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
export interface IRuLIBPopular {
|
||||
id: number;
|
||||
name: string;
|
||||
rus_name: string;
|
||||
eng_name: string;
|
||||
slug: string;
|
||||
slug_url: string;
|
||||
cover: Cover;
|
||||
ageRestriction: AgeRestriction;
|
||||
site: number;
|
||||
type: AgeRestriction;
|
||||
rating: Rating;
|
||||
last_item_at: Date;
|
||||
metadata: Metadata;
|
||||
model: Model;
|
||||
status: AgeRestriction;
|
||||
releaseDateString: string;
|
||||
}
|
||||
|
||||
export interface AgeRestriction {
|
||||
id: number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface Cover {
|
||||
filename: string;
|
||||
thumbnail: string;
|
||||
default: string;
|
||||
md: string;
|
||||
}
|
||||
|
||||
export interface Metadata {
|
||||
last_item: LastItem;
|
||||
}
|
||||
|
||||
export interface LastItem {
|
||||
id: number;
|
||||
number: string;
|
||||
volume: number | string;
|
||||
name: string;
|
||||
branch_id: number | null;
|
||||
status?: null;
|
||||
type?: string;
|
||||
number_secondary?: string;
|
||||
slug?: number;
|
||||
manga_id?: null;
|
||||
created_at?: Date;
|
||||
likes_count?: null;
|
||||
}
|
||||
|
||||
export enum Model {
|
||||
Manga = "manga",
|
||||
}
|
||||
|
||||
export interface Rating {
|
||||
average: string;
|
||||
averageFormated: string;
|
||||
votes: number;
|
||||
votesFormated: string;
|
||||
user: number;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
export interface IRulibSearchResult {
|
||||
data: Datum[];
|
||||
links: Links;
|
||||
meta: Meta;
|
||||
}
|
||||
|
||||
//TODO: Make normal namings
|
||||
export interface Datum {
|
||||
id: number;
|
||||
name: string;
|
||||
rus_name: string;
|
||||
eng_name: string;
|
||||
slug: string;
|
||||
slug_url: string;
|
||||
cover: Cover;
|
||||
ageRestriction: AgeRestriction;
|
||||
site: number;
|
||||
type: AgeRestriction;
|
||||
rating: Rating;
|
||||
is_licensed: boolean;
|
||||
model: Model;
|
||||
status: AgeRestriction;
|
||||
releaseDateString: string;
|
||||
}
|
||||
|
||||
export interface AgeRestriction {
|
||||
id: number;
|
||||
label: Label;
|
||||
}
|
||||
|
||||
export enum Label {
|
||||
The12 = "12+",
|
||||
The6 = "6+",
|
||||
Завершён = "Завершён",
|
||||
КомиксЗападный = "Комикс западный",
|
||||
Манга = "Манга",
|
||||
Манхва = "Манхва",
|
||||
Маньхуа = "Маньхуа",
|
||||
Нет = "Нет",
|
||||
Онгоинг = "Онгоинг",
|
||||
Приостановлен = "Приостановлен",
|
||||
}
|
||||
|
||||
export interface Cover {
|
||||
filename: string;
|
||||
thumbnail: string;
|
||||
default: string;
|
||||
md: string;
|
||||
}
|
||||
|
||||
export enum Model {
|
||||
Manga = "manga",
|
||||
}
|
||||
|
||||
export interface Rating {
|
||||
average: string;
|
||||
averageFormated: string;
|
||||
votes: number;
|
||||
votesFormated: string;
|
||||
user: number;
|
||||
}
|
||||
|
||||
export interface Links {
|
||||
first: string;
|
||||
last: null;
|
||||
prev: null;
|
||||
next: string;
|
||||
}
|
||||
|
||||
export interface Meta {
|
||||
current_page: number;
|
||||
from: number;
|
||||
path: string;
|
||||
per_page: number;
|
||||
to: number;
|
||||
page: number;
|
||||
has_next_page: boolean;
|
||||
seed: string;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { ParserDecorator } from "../decorators/parser.decorator";
|
||||
import { ESiteUrls } from "../urls";
|
||||
import { LibSocialParserService } from "./lib.social.parser.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
@ParserDecorator({ site_name: "Slashlib", url: ESiteUrls.LIB_SOCIAL, site_id: 2 })
|
||||
export class SlashlibParserService extends LibSocialParserService {}
|
||||
3
apps/NwaifuAnime/src/app/services/parsers/token.dto.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface IToken {
|
||||
rulib_token?: string;
|
||||
}
|
||||
5
apps/NwaifuAnime/src/app/services/parsers/urls.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum ESiteUrls {
|
||||
LIB_SOCIAL = "https://api.lib.social",
|
||||
MANGALIB = "https://api.mangalib.me",
|
||||
SLASHLIB = "https://api.slashlib.me",
|
||||
}
|
||||
89
apps/NwaifuAnime/src/app/services/search.service.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { Observable, map } from "rxjs";
|
||||
import { EParser } from "./parsers/enums/parser";
|
||||
import { Parser } from "./parsers/parser";
|
||||
import { IRulibChapterResult } from "./parsers/rulib/rulib.chapter.dto";
|
||||
import { IRulibChaptersResult } from "./parsers/rulib/rulib.chapters.dto";
|
||||
import { IRulibDetailResult } from "./parsers/rulib/rulib.detail.dto";
|
||||
import { IRulibSearchResult } from "./parsers/rulib/rulib.search.dto";
|
||||
|
||||
@Injectable({ providedIn: "root" })
|
||||
export class SearchService {
|
||||
private parser!: Parser;
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
@Inject(Parser) private parsers: Parser[],
|
||||
) {}
|
||||
|
||||
setMangalibParser() {
|
||||
this.setParser(EParser.MangaLib);
|
||||
}
|
||||
|
||||
setSlashlibParser() {
|
||||
this.setParser(EParser.SlashLib);
|
||||
}
|
||||
|
||||
private setParser(parser: EParser) {
|
||||
this.parser = this.parsers[parser];
|
||||
}
|
||||
|
||||
search(query: string): Observable<IRulibSearchResult> {
|
||||
return this.parser.searchManga(query).pipe(
|
||||
map((data) => {
|
||||
return data as IRulibSearchResult;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getDetails(slug_url: string): Observable<IRulibDetailResult> {
|
||||
return this.parser.getDetails(slug_url).pipe(
|
||||
map((data) => {
|
||||
return data as IRulibDetailResult;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getChapters(url: string): Observable<IRulibChaptersResult> {
|
||||
return this.parser.getChapters(url).pipe(
|
||||
map((data) => {
|
||||
return data as IRulibChaptersResult;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getChapter(url: string, chapter: string, volume: string): Observable<IRulibChapterResult> {
|
||||
return this.parser.getChapter(url, chapter, volume).pipe(
|
||||
map((data) => {
|
||||
return data as IRulibChapterResult;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getImageServer() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (this.parser as any).imageServer;
|
||||
}
|
||||
|
||||
getImageData(imageUrl: string): Observable<Uint8Array> {
|
||||
return this.http.get(imageUrl, { responseType: "arraybuffer" }).pipe(
|
||||
map((arrayBuffer: ArrayBuffer) => {
|
||||
return new Uint8Array(arrayBuffer);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
isManhwa(url: string): Observable<boolean> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (this.parser as any).isManhwa(url);
|
||||
}
|
||||
|
||||
getPopular(): Observable<object[]> {
|
||||
return this.parser.getPopular();
|
||||
}
|
||||
|
||||
getRuLibName(): string {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (this.parser as any).site_name;
|
||||
}
|
||||
}
|
||||
17
apps/NwaifuAnime/src/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>NwaifuAnime</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
<link href="https://cdn.lineicons.com/4.0/lineicons.css" rel="stylesheet" />
|
||||
<link rel="manifest" href="manifest.webmanifest" />
|
||||
<meta name="theme-color" content="#1976d2" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<noscript>Please enable JavaScript to continue using this application.</noscript>
|
||||
</body>
|
||||
</html>
|
||||
5
apps/NwaifuAnime/src/main.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { bootstrapApplication } from "@angular/platform-browser";
|
||||
import { appConfig } from "./app/app.config";
|
||||
import { AppComponent } from "./app/app.component";
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
|
||||
6
apps/NwaifuAnime/src/styles.less
Normal file
@@ -0,0 +1,6 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
body {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
14
apps/NwaifuAnime/tailwind.config.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const { createGlobPatternsForDependencies } = require("@nx/angular/tailwind");
|
||||
const { join } = require("path");
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: [
|
||||
join(__dirname, "src/**/!(*.stories|*.spec).{ts,html}"),
|
||||
...createGlobPatternsForDependencies(__dirname),
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
10
apps/NwaifuAnime/tsconfig.app.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"types": []
|
||||
},
|
||||
"files": ["src/main.ts"],
|
||||
"include": ["src/**/*.d.ts"],
|
||||
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
||||
}
|
||||
6
apps/NwaifuAnime/tsconfig.editor.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src/**/*.ts"],
|
||||
"compilerOptions": {},
|
||||
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
||||
}
|
||||
30
apps/NwaifuAnime/tsconfig.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.editor.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
}
|
||||
],
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
41
apps/NwaifuWeb/.eslintrc.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@angular-eslint/recommended",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "app",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "app",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.html"],
|
||||
"extends": [
|
||||
"plugin:@angular-eslint/template/recommended",
|
||||
"plugin:@angular-eslint/template/accessibility"
|
||||
],
|
||||
"rules": {}
|
||||
}
|
||||
],
|
||||
"extends": "../../.eslintrc.json"
|
||||
}
|
||||
86
apps/NwaifuWeb/project.json
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "NwaifuWeb",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"generators": {
|
||||
"@schematics/angular:component": {
|
||||
"style": "less"
|
||||
}
|
||||
},
|
||||
"sourceRoot": "apps/NwaifuWeb/src",
|
||||
"prefix": "app",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@angular-devkit/build-angular:application",
|
||||
"options": {
|
||||
"outputPath": "dist/apps/NwaifuWeb",
|
||||
"index": "apps/NwaifuWeb/src/index.html",
|
||||
"browser": "apps/NwaifuWeb/src/main.ts",
|
||||
"polyfills": ["zone.js"],
|
||||
"tsConfig": "apps/NwaifuWeb/tsconfig.app.json",
|
||||
"inlineStyleLanguage": "less",
|
||||
"assets": ["apps/NwaifuWeb/src/favicon.ico", "apps/NwaifuWeb/src/assets"],
|
||||
"styles": ["apps/NwaifuWeb/src/styles.less"],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "NwaifuWeb:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "NwaifuWeb:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "NwaifuWeb:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"polyfills": ["zone.js", "zone.js/testing"],
|
||||
"tsConfig": "apps/NwaifuWeb/tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "less",
|
||||
"assets": ["apps/NwaifuWeb/src/favicon.ico", "apps/NwaifuWeb/src/assets"],
|
||||
"styles": ["apps/NwaifuWeb/src/styles.less"],
|
||||
"scripts": []
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"options": {
|
||||
"lintFilePatterns": ["apps/NwaifuWeb/**/*.ts", "apps/NwaifuWeb/**/*.html"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
apps/NwaifuWeb/src/app/app.component.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<header>
|
||||
<app-panel></app-panel>
|
||||
</header>
|
||||
<main>
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
8
apps/NwaifuWeb/src/app/app.component.less
Normal file
@@ -0,0 +1,8 @@
|
||||
main {
|
||||
overflow-y: auto;
|
||||
width: 100%;
|
||||
height: calc(100% - 2rem);
|
||||
background-image: url("../assets/img/wallpaper.png");
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
import { TestBed } from "@angular/core/testing";
|
||||
import { AppComponent } from "./app.component";
|
||||
|
||||
describe('AppComponent', () => {
|
||||
describe("AppComponent", () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AppComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('should create the app', () => {
|
||||
it("should create the app", () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
@@ -17,13 +17,13 @@ describe('AppComponent', () => {
|
||||
it(`should have the 'NwaifuWeb' title`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app.title).toEqual('NwaifuWeb');
|
||||
expect(app.title).toEqual("NwaifuWeb");
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
it("should render title", () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, NwaifuWeb');
|
||||
expect(compiled.querySelector("h1")?.textContent).toContain("Hello, NwaifuWeb");
|
||||
});
|
||||
});
|
||||
14
apps/NwaifuWeb/src/app/app.component.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Component } from "@angular/core";
|
||||
import { RouterModule } from "@angular/router";
|
||||
import { PanelComponent } from "./modules/panel/panel.component";
|
||||
|
||||
@Component({
|
||||
selector: "app-root",
|
||||
standalone: true,
|
||||
imports: [PanelComponent, RouterModule],
|
||||
templateUrl: "./app.component.html",
|
||||
styleUrl: "./app.component.less",
|
||||
})
|
||||
export class AppComponent {
|
||||
title = "Nwaifu";
|
||||
}
|
||||
25
apps/NwaifuWeb/src/app/app.config.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { APP_INITIALIZER, ApplicationConfig } from "@angular/core";
|
||||
|
||||
import { provideHttpClient } from "@angular/common/http";
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { routes } from './app.routes';
|
||||
import { TranslateService } from "./services/translate.service";
|
||||
|
||||
export function setupTranslateServiceFactory(service: TranslateService) {
|
||||
const lang = localStorage.getItem("lang") ?? "en";
|
||||
return () => service.use(lang);
|
||||
}
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideRouter(routes),
|
||||
provideHttpClient(),
|
||||
TranslateService,
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: setupTranslateServiceFactory,
|
||||
deps: [TranslateService],
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
19
apps/NwaifuWeb/src/app/app.routes.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Routes } from "@angular/router";
|
||||
import { MainPageComponent } from './pages/main/main.component';
|
||||
import { NitroplusComponent } from './pages/nitroplus-translator/nitroplus-translator.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: MainPageComponent
|
||||
},
|
||||
{
|
||||
path: 'translator',
|
||||
component: NitroplusComponent
|
||||
}
|
||||
]
|
||||
},
|
||||
];
|
||||
6
apps/NwaifuWeb/src/app/interfaces/link.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface Link {
|
||||
id: number;
|
||||
text: string;
|
||||
url: string;
|
||||
svg: string;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<div class="desktop-icon">
|
||||
<img [src]="image" [alt]="alt" [title]="name" />
|
||||
<span>{{ name }}</span>
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
.desktop-icon {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 5rem;
|
||||
height: 6rem;
|
||||
color: white;
|
||||
font-size: 0.7rem;
|
||||
user-select: none;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
transition: 0.2s ease-in-out;
|
||||
&:hover {
|
||||
background-color: rgba(25, 17, 19, 0.7);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'desktop-icon',
|
||||
templateUrl: './desktop-icon.component.html',
|
||||
styleUrls: ['./desktop-icon.component.less'],
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterModule]
|
||||
})
|
||||
export class DesktopIconComponent {
|
||||
@Input() image: string = '';
|
||||
@Input() alt: string = '';
|
||||
@Input() name: string = '';
|
||||
@Input({required: false}) click: ()=>void = ()=>{};
|
||||
}
|
||||
5
apps/NwaifuWeb/src/app/modules/dock/dock.component.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<section class="dock">
|
||||
@for(link of links; track link.id) {
|
||||
<app-link [url]="link.url" [svg]="link.svg" [text]="link.text"></app-link>
|
||||
}
|
||||
</section>
|
||||
27
apps/NwaifuWeb/src/app/modules/dock/dock.component.less
Normal file
@@ -0,0 +1,27 @@
|
||||
.dock {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 0;
|
||||
transform: translateX(-50%);
|
||||
width: 330px;
|
||||
height: 100px;
|
||||
background-color: rgba(171, 178, 181, 30%);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 1rem;
|
||||
margin-block-end: 1rem;
|
||||
border-radius: 35px;
|
||||
app-link {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0 0.5rem;
|
||||
&:first-child {
|
||||
padding-inline-start: 0;
|
||||
}
|
||||
&:last-child {
|
||||
padding-inline-end: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
apps/NwaifuWeb/src/app/modules/dock/dock.component.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component } from "@angular/core";
|
||||
import { Link } from "../../interfaces/link";
|
||||
import { LinkComponent } from "../link/link.component";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: "app-dock",
|
||||
imports: [CommonModule, LinkComponent],
|
||||
templateUrl: "./dock.component.html",
|
||||
styleUrls: ["./dock.component.less"],
|
||||
})
|
||||
export class DockComponent {
|
||||
readonly links: Link[] = [
|
||||
{
|
||||
id: 0,
|
||||
svg: "../../../assets/svg/logo-telegram.svg",
|
||||
url: "https://t.me/neur0w0men",
|
||||
text: "TELEGRAM_LABEL",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
svg: "../../../assets/svg/logo-github.svg",
|
||||
url: "https://github.com/MrSedan",
|
||||
text: "GITHUB_LABEL",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
svg: "../../../assets/svg/logo-gitea.svg",
|
||||
url: "https://git.nwaifu.su",
|
||||
text: "GITEA_LABEL",
|
||||
},
|
||||
];
|
||||
}
|
||||
4
apps/NwaifuWeb/src/app/modules/link/link.component.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<a [href]="url">
|
||||
<img [src]="svg" [alt]="url" [title]="text | translate" />
|
||||
<span>{{ text | translate }}</span>
|
||||
</a>
|
||||
36
apps/NwaifuWeb/src/app/modules/link/link.component.less
Normal file
@@ -0,0 +1,36 @@
|
||||
img {
|
||||
width: 100%;
|
||||
height: 70px;
|
||||
margin: auto 0;
|
||||
}
|
||||
a {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 0;
|
||||
transition: 0.5s ease-in-out;
|
||||
span {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: scale(0);
|
||||
overflow: hidden;
|
||||
color: var(--white);
|
||||
text-align: center;
|
||||
font-size: 0.8rem;
|
||||
height: 0;
|
||||
font-weight: 600;
|
||||
transition: all 0.6s ease-in-out;
|
||||
}
|
||||
&:hover {
|
||||
transform: translateY(-1rem);
|
||||
span {
|
||||
opacity: 1;
|
||||
height: auto;
|
||||
transform: scale(1);
|
||||
visibility: visible;
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
apps/NwaifuWeb/src/app/modules/link/link.component.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, Input } from "@angular/core";
|
||||
import { TranslationPipe } from "../../pipes/translation.pipe";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: "app-link",
|
||||
imports: [CommonModule, TranslationPipe],
|
||||
templateUrl: "./link.component.html",
|
||||
styleUrls: ["./link.component.less"],
|
||||
})
|
||||
export class LinkComponent {
|
||||
@Input() url: string = "#";
|
||||
@Input() svg: string = "";
|
||||
@Input() text: string = "";
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<div class="modal-window" #modal></div>
|
||||
31
apps/NwaifuWeb/src/app/modules/modal/modal.component.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component, ElementRef, ViewChild } from "@angular/core";
|
||||
import { DialogRef, DialogService } from "@ngneat/dialog";
|
||||
import { WindowComponent } from "../window/window.component";
|
||||
|
||||
@Component({
|
||||
selector: "app-modal",
|
||||
templateUrl: "./modal.component.html",
|
||||
styleUrls: ["./modal.component.less"],
|
||||
imports: [CommonModule],
|
||||
standalone: true,
|
||||
})
|
||||
export class ModalComponent implements AfterViewInit {
|
||||
dialogRef: DialogRef | undefined = undefined;
|
||||
@ViewChild("modal") modal: ElementRef | undefined = undefined;
|
||||
constructor(private dialogService: DialogService, private ref: ElementRef) {}
|
||||
ngAfterViewInit(): void {
|
||||
this.dialogRef = this.dialogService.open(WindowComponent, {
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
backdrop: false,
|
||||
closeButton: false,
|
||||
container: this.modal ?? this.ref,
|
||||
enableClose: false,
|
||||
dragConstraint: "constrain",
|
||||
id: "info-modal",
|
||||
minWidth: "300px",
|
||||
minHeight: "10rem",
|
||||
});
|
||||
}
|
||||
}
|
||||
29
apps/NwaifuWeb/src/app/modules/panel/panel.component.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="panel">
|
||||
<div class="desktops">
|
||||
<div class="ellipse"></div>
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="time">
|
||||
<span>{{ time }}</span>
|
||||
</div>
|
||||
<div class="right-menu">
|
||||
<span
|
||||
class="lang cursor-pointer"
|
||||
(click)="toggleModal()"
|
||||
(keydown)="toggleModal()"
|
||||
tabindex="0"
|
||||
#lang_btn
|
||||
>{{ getLang() }}</span
|
||||
>
|
||||
<a href="https://git.nwaifu.su/neuro_llc/NwaifuWeb" [title]="source_code_btn_title | translate">
|
||||
<fa-icon [icon]="faGithub" class="sourcecode-icon"></fa-icon>
|
||||
</a>
|
||||
<fa-icon [icon]="faVolume"></fa-icon>
|
||||
<fa-icon [icon]="faPower"></fa-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lang-choose" #lang_modal>
|
||||
<p (click)="useLang('en')" (keypress)="useLang('en')" tabindex="0"><b>en</b> - English</p>
|
||||
<p (click)="useLang('ru')" (keypress)="useLang('ru')" tabindex="0"><b>ru</b> - Русский</p>
|
||||
<p (click)="useLang('ja')" (keypress)="useLang('ja')" tabindex="0"><b>ja</b> - 日本語</p>
|
||||
</div>
|
||||
107
apps/NwaifuWeb/src/app/modules/panel/panel.component.less
Normal file
@@ -0,0 +1,107 @@
|
||||
.panel {
|
||||
z-index: 99999;
|
||||
position: relative;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 2rem;
|
||||
background-color: #000;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.desktops {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: auto;
|
||||
height: 100%;
|
||||
.ellipse {
|
||||
width: 60px;
|
||||
height: 0.8rem;
|
||||
border-radius: 50px;
|
||||
background-color: var(--white);
|
||||
}
|
||||
.circle {
|
||||
width: 0.8rem;
|
||||
height: 0.8rem;
|
||||
border-radius: 50px;
|
||||
background-color: #b1b2b5;
|
||||
}
|
||||
}
|
||||
.time {
|
||||
margin: auto 0;
|
||||
width: auto;
|
||||
span {
|
||||
font-weight: 600;
|
||||
color: var(--white);
|
||||
line-height: 100%;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.right-menu {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
gap: 0.7rem;
|
||||
color: var(--white);
|
||||
margin: auto 0;
|
||||
align-items: center;
|
||||
span {
|
||||
font-weight: 600;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
fa-icon {
|
||||
font-size: 1.2rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.lang-choose {
|
||||
position: absolute;
|
||||
display: none;
|
||||
&.active {
|
||||
display: flex;
|
||||
}
|
||||
top: 0;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
gap: 0;
|
||||
background-color: var(--black);
|
||||
margin-block-start: 3rem;
|
||||
z-index: 9999;
|
||||
margin-inline-end: 1rem;
|
||||
color: var(--white);
|
||||
padding: 1rem 0;
|
||||
border-radius: 15px;
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) rotate(45deg);
|
||||
vertical-align: middle;
|
||||
top: -0.5rem;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border: 10px solid var(--black);
|
||||
}
|
||||
p {
|
||||
line-height: 2rem;
|
||||
width: 100%;
|
||||
padding: 0.5rem 1rem;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
background-color: #000;
|
||||
}
|
||||
}
|
||||
}
|
||||
88
apps/NwaifuWeb/src/app/modules/panel/panel.component.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, ElementRef, HostListener, ViewChild } from "@angular/core";
|
||||
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
|
||||
import { faGithub } from "@fortawesome/free-brands-svg-icons";
|
||||
import { faPowerOff, faVolumeHigh } from "@fortawesome/free-solid-svg-icons";
|
||||
import { TranslationPipe } from "../../pipes/translation.pipe";
|
||||
import { PanelSevice } from "../../services/panel.service";
|
||||
import { TranslateService } from "../../services/translate.service";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: "app-panel",
|
||||
imports: [CommonModule, FontAwesomeModule, TranslationPipe],
|
||||
templateUrl: "./panel.component.html",
|
||||
styleUrls: ["./panel.component.less"],
|
||||
})
|
||||
export class PanelComponent {
|
||||
source_code_btn_title = "SOURCE_CODE_TITLE";
|
||||
|
||||
public time = "";
|
||||
faGithub = faGithub;
|
||||
faVolume = faVolumeHigh;
|
||||
faPower = faPowerOff;
|
||||
showLangModalBool = false;
|
||||
@ViewChild("lang_modal") langModal: ElementRef<HTMLDivElement> | null = null;
|
||||
@ViewChild("lang_btn") langBtn: ElementRef<HTMLSpanElement> | null = null;
|
||||
|
||||
constructor(private panelService: PanelSevice, private translateService: TranslateService) {
|
||||
this.time = this.getTime();
|
||||
setInterval(() => {
|
||||
this.time = this.getTime();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private getTime() {
|
||||
const time = this.panelService.getTime();
|
||||
return time.toLocaleDateString(this.translateService.translate("TIME_SCHEMA"), {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
});
|
||||
}
|
||||
|
||||
goToSource() {
|
||||
window.open("https://git.nwaifu.su/neuro_llc/NwaifuWeb", "_blank");
|
||||
}
|
||||
|
||||
@HostListener("window:resize")
|
||||
private moveLangModal() {
|
||||
if (!this.langModal || !this.langBtn) {
|
||||
return;
|
||||
}
|
||||
|
||||
const x = this.langBtn.nativeElement.getBoundingClientRect().x;
|
||||
this.langModal.nativeElement.style.left = `calc(${x}px - 3.5rem)`;
|
||||
}
|
||||
|
||||
@HostListener("window:click", ["$event"])
|
||||
private closeLangModal(event: MouseEvent) {
|
||||
if (
|
||||
this.langModal &&
|
||||
this.langBtn &&
|
||||
!this.langModal.nativeElement.contains(event.target as Node) &&
|
||||
!this.langBtn.nativeElement.contains(event.target as Node)
|
||||
) {
|
||||
this.langModal.nativeElement.classList.remove("active");
|
||||
}
|
||||
}
|
||||
|
||||
toggleModal() {
|
||||
if (this.langModal) {
|
||||
this.langModal.nativeElement.classList.toggle("active");
|
||||
if (this.langModal.nativeElement.classList.contains("active")) {
|
||||
this.moveLangModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
useLang(lang: string) {
|
||||
this.langModal && this.langModal.nativeElement.classList.remove("active");
|
||||
this.translateService.use(lang);
|
||||
}
|
||||
|
||||
getLang() {
|
||||
return this.translateService.lang;
|
||||
}
|
||||
}
|
||||
10
apps/NwaifuWeb/src/app/modules/window/window.component.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="panel">
|
||||
<span>{{ modal_title | translate }}</span>
|
||||
<div class="btns">
|
||||
<fa-icon [icon]="faMenu"></fa-icon>
|
||||
<fa-icon [icon]="faClose"></fa-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<h1>{{ modal_text | translate }}</h1>
|
||||
</div>
|
||||
24
apps/NwaifuWeb/src/app/modules/window/window.component.less
Normal file
@@ -0,0 +1,24 @@
|
||||
.panel {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
height: 3rem;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 1rem;
|
||||
background-color: var(--black);
|
||||
color: var(--white);
|
||||
span {
|
||||
font-size: 600;
|
||||
}
|
||||
.btns {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
.content {
|
||||
margin: 1rem;
|
||||
}
|
||||
22
apps/NwaifuWeb/src/app/modules/window/window.component.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component } from "@angular/core";
|
||||
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
|
||||
import { faBars, faXmark } from "@fortawesome/free-solid-svg-icons";
|
||||
import { DialogRef } from "@ngneat/dialog";
|
||||
import { TranslationPipe } from "../../pipes/translation.pipe";
|
||||
|
||||
@Component({
|
||||
selector: "app-window",
|
||||
standalone: true,
|
||||
imports: [CommonModule, FontAwesomeModule, TranslationPipe],
|
||||
templateUrl: "./window.component.html",
|
||||
styleUrls: ["./window.component.less"],
|
||||
// changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class WindowComponent {
|
||||
modal_text = "MODAL_TEXT";
|
||||
modal_title = "MODAL_TITLE";
|
||||
faClose = faXmark;
|
||||
faMenu = faBars;
|
||||
constructor(public ref: DialogRef) {}
|
||||
}
|
||||