refactor: 移动 Context 初始化到 MainLayout 组件中

This commit is contained in:
Argo-Tianyi 2022-01-25 00:39:47 +08:00
parent 10e5b1d26c
commit 331f034d9b
4 changed files with 1 additions and 33 deletions

View File

@ -2,7 +2,6 @@
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<PageTitle>@Title</PageTitle>
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
</AuthorizeRouteView>
</Found>

View File

@ -1,32 +0,0 @@
using BootstrapAdmin.Web.Services;
namespace BootstrapAdmin.Web;
/// <summary>
///
/// </summary>
public partial class App
{
/// <summary>
///
/// </summary>
public string? Title { get; set; }
[Inject]
[NotNull]
private BootstrapAppContext? AppContext { get; set; }
[Inject]
[NotNull]
private NavigationManager? NavigationManager { get; set; }
/// <summary>
///
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
AppContext.BaseUri = NavigationManager.ToAbsoluteUri(NavigationManager.BaseUri);
}
}

View File

@ -88,6 +88,7 @@ namespace BootstrapAdmin.Web.Shared
{
base.OnInitialized();
AppContext.BaseUri = NavigationManager.ToAbsoluteUri(NavigationManager.BaseUri);
NavigationManager.LocationChanged += NavigationManager_LocationChanged;
}