refactor: 移动 Context 初始化到 MainLayout 组件中
This commit is contained in:
parent
10e5b1d26c
commit
331f034d9b
|
@ -2,7 +2,6 @@
|
||||||
<CascadingAuthenticationState>
|
<CascadingAuthenticationState>
|
||||||
<Router AppAssembly="@typeof(App).Assembly">
|
<Router AppAssembly="@typeof(App).Assembly">
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
<PageTitle>@Title</PageTitle>
|
|
||||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
||||||
</AuthorizeRouteView>
|
</AuthorizeRouteView>
|
||||||
</Found>
|
</Found>
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -88,6 +88,7 @@ namespace BootstrapAdmin.Web.Shared
|
||||||
{
|
{
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
|
|
||||||
|
AppContext.BaseUri = NavigationManager.ToAbsoluteUri(NavigationManager.BaseUri);
|
||||||
NavigationManager.LocationChanged += NavigationManager_LocationChanged;
|
NavigationManager.LocationChanged += NavigationManager_LocationChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue