Redirect first-time visitors to info page

Updated routing to use MainPage as the default route and added logic in App component to redirect users to the /info page on their first visit using sessionStorage.
This commit is contained in:
2025-10-26 00:40:14 +02:00
parent e9f25fe66a
commit 7ffec411ad
2 changed files with 17 additions and 3 deletions

View File

@@ -2,9 +2,11 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { PocModelComponent } from './poc-model-component/poc-model-component';
import { HomeComponent } from './home-component/home-component';
import { MainPage } from './main-page/main-page';
const routes: Routes = [
{ path: '', component: HomeComponent, pathMatch: 'full' },
{ path: '', component: MainPage, pathMatch: 'full' },
{ path: 'info', component: HomeComponent },
{ path: 'poc-model', component: PocModelComponent },
{ path: '**', component: HomeComponent },
];

View File

@@ -1,4 +1,5 @@
import { Component, signal } from '@angular/core';
import { Component, OnInit, signal } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-root',
@@ -6,6 +7,17 @@ import { Component, signal } from '@angular/core';
standalone: false,
styleUrl: './app.css',
})
export class App {
export class App implements OnInit{
protected readonly title = signal('infinifront');
constructor(private router: Router) {}
ngOnInit(): void {
const hasVisited = sessionStorage.getItem('hasVisited');
if (!hasVisited) {
sessionStorage.setItem('hasVisited', 'true');
this.router.navigateByUrl('/info', { skipLocationChange: true });
}
}
}