feat(routing): enhance routing for Tauri with dynamic component loading and additional paths

This commit is contained in:
4gray committed 2024-12-16 01:37:55 +01:00
1 parent 9ffef67813
commit 1827afb783
1 file changed
+88 -8
+88 -8
View File
@@ -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 {}