From 1827afb783819d2df8f0158206c142cf43f0e3bd Mon Sep 17 00:00:00 2001 From: 4gray Date: Mon, 16 Dec 2024 01:37:55 +0100 Subject: [PATCH] feat(routing): enhance routing for Tauri with dynamic component loading and additional paths --- src/app/app-routing.module.ts | 96 ++++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 8 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index f24562faf..cd6100c94 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,5 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { isTauri } from '@tauri-apps/api/core'; +import { XtreamStore } from './xtream-tauri/xtream.store'; const routes: Routes = [ { @@ -35,13 +37,85 @@ const routes: Routes = [ (c) => c.SettingsComponent ), }, - { - path: 'xtreams/:id', - loadComponent: () => - import('./xtream/xtream-main-container.component').then( - (c) => c.XtreamMainContainerComponent - ), - }, + ...(isTauri() + ? [ + { + path: 'xtreams/:id', + loadComponent: () => + import( + './xtream-tauri/xtream-main-container.component' + ).then((c) => c.XtreamMainContainerComponent), + providers: [XtreamStore], + children: [ + { + path: '', + loadComponent: () => + import( + './xtream-tauri/category-content-view/category-content-view.component' + ).then((c) => c.CategoryContentViewComponent), + }, + { + path: 'favorites', + loadComponent: () => + import( + './xtream-tauri/favorites/favorites.component' + ).then((c) => c.FavoritesComponent), + }, + { + path: 'recent', + loadComponent: () => + import( + './xtream-tauri/recently-viewed/recently-viewed.component' + ).then((c) => c.RecentlyViewedComponent), + }, + + { + path: 'search', + loadComponent: () => + import( + './xtream-tauri/search-results/search-results.component' + ).then((c) => c.SearchResultsComponent), + }, + { + path: 'live', + loadComponent: () => + import( + './xtream-tauri/live-stream-layout/live-stream-layout.component' + ).then((c) => c.LiveStreamLayoutComponent), + }, + { + path: ':categoryId', + loadComponent: () => + import( + './xtream-tauri/category-content-view/category-content-view.component' + ).then((c) => c.CategoryContentViewComponent), + }, + { + path: ':categoryId/vod/:vodId', + loadComponent: () => + import( + './xtream-tauri/vod-details/vod-details.component' + ).then((c) => c.VodDetailsComponent), + }, + { + path: ':categoryId/series/:serialId', + loadComponent: () => + import( + './xtream-tauri/serial-details/serial-details.component' + ).then((c) => c.SerialDetailsComponent), + }, + ], + }, + ] + : [ + { + path: 'xtreams/:id', + loadComponent: () => + import('./xtream/xtream-main-container.component').then( + (c) => c.XtreamMainContainerComponent + ), + }, + ]), { path: 'portals/:id', loadComponent: () => @@ -56,7 +130,13 @@ const routes: Routes = [ ]; @NgModule({ - imports: [RouterModule.forRoot(routes, {})], + imports: [ + RouterModule.forRoot( + routes /* { + enableTracing: true, + } */ + ), + ], exports: [RouterModule], }) export class AppRoutingModule {}