fix: DefaultLayout 组件 HomeUrl 属性支持 PathBase

This commit is contained in:
Argo Zhang 2020-02-11 15:57:33 +08:00
parent 1867653767
commit 43fdbf1d03
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
3 changed files with 12 additions and 6 deletions

View File

@ -115,11 +115,17 @@ namespace Bootstrap.Admin.Pages.Components
/// <summary> /// <summary>
/// 设置参数方法 /// 设置参数方法
/// </summary> /// </summary>
protected override void OnParametersSet() public override Task SetParametersAsync(ParameterView parameters)
{ {
RequestUrl = new UriBuilder(NavigationManager?.Uri ?? "").Path; parameters.SetParameterProperties(this);
Model = new NavigatorBarModel(UserName, RequestUrl.ToMvcMenuUrl()); if (NavigationManager != null)
DisplayName = Model.DisplayName; {
RequestUrl = new UriBuilder(NavigationManager.Uri).Path;
Model = new NavigatorBarModel(UserName, RequestUrl.ToMvcMenuUrl());
DisplayName = Model.DisplayName;
HomeUrl = NavigationManager.ToBlazorLink(HomeUrl);
}
return base.SetParametersAsync(ParameterView.Empty);
} }
/// <summary> /// <summary>

View File

@ -25,7 +25,7 @@ namespace Bootstrap.Admin.Pages.Components
/// 获得 根模板页实例 /// 获得 根模板页实例
/// </summary> /// </summary>
[CascadingParameter(Name = "Default")] [CascadingParameter(Name = "Default")]
public DefaultLayout RootLayout { get; protected set; } = new DefaultLayout(); public DefaultLayout? RootLayout { get; protected set; }
/// <summary> /// <summary>
/// 获得/设置 用户显示名称 /// 获得/设置 用户显示名称

View File

@ -3,7 +3,7 @@
<aside class="@Model.ShowSideBar"> <aside class="@Model.ShowSideBar">
<div class="bg"></div> <div class="bg"></div>
<div class="nav-brand justify-content-center"> <div class="nav-brand justify-content-center">
<a href="@NavigationManager.ToBlazorLink(RootLayout.HomeUrl)"> <a href="@RootLayout?.HomeUrl">
<img src="@Model.WebSiteLogo.ToBlazorLink()" /> <img src="@Model.WebSiteLogo.ToBlazorLink()" />
<span>@Model.Title</span> <span>@Model.Title</span>
</a> </a>