Files
pos-system/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Auth/AuthBase.cs

34 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Microsoft.JSInterop;
namespace WebClientTpos.Client.Pages.Auth;
/// <summary>
/// EN: Base class for all auth pages — handles Lucide icon initialization and localization.
/// VI: Lớp cơ sở cho tất cả trang auth — xử lý khởi tạo Lucide icons và đa ngôn ngữ.
/// </summary>
public abstract class AuthBase : ComponentBase
{
[Inject] protected IJSRuntime JS { get; set; } = default!;
[Inject] protected NavigationManager Navigation { get; set; } = default!;
[Inject] protected IStringLocalizer<AuthBase> L { get; set; } = default!;
/// <summary>
/// EN: Initialize Lucide icons after each render (SPA navigation creates new DOM).
/// VI: Khởi tạo Lucide icons sau mỗi lần render (SPA navigation tạo DOM mới).
/// </summary>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
try
{
await JS.InvokeVoidAsync("lucide.createIcons");
}
catch
{
// EN: Lucide script may not be loaded yet during prerender or JS interop unavailable.
// VI: Script Lucide có thể chưa load xong khi prerender hoặc JS interop chưa sẵn sàng.
}
}
}