[] 리다이렉트 경로 설정 및 기타 코드 학습

This commit is contained in:
김선규 2025-05-07 17:31:37 +09:00
parent c21f44e124
commit 4f9361d7fb
7 changed files with 40 additions and 7 deletions

View File

@ -1,10 +1,31 @@
<Router AppAssembly="@typeof(App).Assembly">
<!--
Router: Blazor의 라우팅 기능을 제공하는 컴포넌트
AppAssembly: 현재 애플리케이션의 어셈블리를 지정
Blazor는 @page가 붙은 .razor 파일을 찾아서 App 어셈블리 안에서 자동으로 라우팅을 찾아 설정
-->
<Router AppAssembly="@typeof(App).Assembly">
@* <!-- *@
@* Found: URL에 해당하는 페이지가 존재해 라우팅이 성공적으로 이루어졌을 때 실행 *@
@* Context="routeData": Found 컴포넌트에 전달된 해당하는 URL 페이지의 라우팅 정보를 routeData 라는 이름으로 사용 *@
@* RouteView: 실제로 해당 URL 에 해당하는 .razor 페이지를 렌더링 *@
@* RouteData="@routeData": Found 에서 전달된 라우팅 결과 *@
@* DefaultLayout="@typeof(MainLayout)": 해당 페이지에 @layout 이 없다면 사용 할 기본 레이아웃을 지정 *@
@* FocusOnNavigate: URL이 변경되었을 때 페이지의 특정 요소에 포커스를 맞추는 컴포넌트 - 접근성이나 키보드 탐색을 위한 UX 개선 요소 *@
@* RouteData="@routeData": Found 에서 전달된 라우팅 결과 *@
@* Selector="h1": 포커스를 맞출 요소를 지정 *@
@* --> *@
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
</Found>
<!--
NotFound: URL에 해당하는 페이지가 존재하지 않을 때 실행
LayoutView: 레이아웃을 지정하는 컴포넌트
Layout="@typeof(MainLayout)": 레이아웃을 지정
role="alert": 스크린 리더와 같은 보조 기술에 의해 읽히는 경고 메시지
-->
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">

View File

@ -29,9 +29,6 @@
<Folder Include="Program\Models\" />
<Folder Include="Program\ViewModels\" />
<Folder Include="Program\Views\Academy\" />
<Folder Include="wwwroot\css\components\base\" />
<Folder Include="wwwroot\css\components\layout\" />
<Folder Include="wwwroot\css\components\reusable\" />
</ItemGroup>

View File

@ -9,6 +9,7 @@
<SideNav />
<main class="flex-1 p-6">
@* <!-- Body는 URL 뒤에 입력할 페이지에 따라서 그거에 맞는 @page를 찾아서 열어준다. --> *@
@Body
</main>
</div>

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components;
namespace Front.Program.Views.Company;
namespace Front.Program.Views.Project;
public partial class About : ComponentBase
{

View File

@ -0,0 +1 @@
@page "/"

View File

@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Components;
namespace Front.Program.Views.Project;
public partial class RedirectPage : ComponentBase
{
[Inject]
private NavigationManager NavigationManager { get; set; } = default!;
protected override void OnInitialized()
{
// Redirect to the desired URL
NavigationManager.NavigateTo("/about",true);
}
}

View File

@ -5,7 +5,6 @@
@* </div> *@
<div class="relative bg-second-darker shadow p-4 flex items-center justify-center">
<!-- 왼쪽 아이콘 -->
<div class="absolute left-4 flex items-center">
<img src="/logo.png" alt="Icon" class="w-8 h-8">
@ -16,5 +15,4 @@
<!-- 오른쪽 가짜 공간 (아이콘 크기만큼) -->
<div class="absolute right-4 w-8 h-8"></div>
</div>