refactor: 重构个人中心更新显示名称功能
This commit is contained in:
parent
0c49b3ebbf
commit
5a9dd7a4d5
|
@ -12,47 +12,47 @@ using System.Threading.Tasks;
|
|||
namespace Bootstrap.Admin.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public class DefaultLayoutComponentBase : LayoutComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public AuthenticationStateProvider AuthenticationStateProvider { get; set; } = new ServerAuthenticationStateProvider();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public NavigationManager? NavigationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public IJSRuntime? JSRuntime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public NavigatorBarModel Model { get; set; } = new NavigatorBarModel("");
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public string UserName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
protected bool IsAdmin { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 系统首页
|
||||
|
@ -103,7 +103,7 @@ namespace Bootstrap.Admin.Components
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public void OnDisplayNameChanged(string displayName)
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace Bootstrap.Admin.Components
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="firstRender"></param>
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
|
|
|
@ -4,36 +4,30 @@ using Microsoft.AspNetCore.Components;
|
|||
namespace Bootstrap.Admin.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public class HeaderBase : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool IsAdmin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string Title { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
[CascadingParameter(Name = "Default")]
|
||||
public DefaultLayout RootLayout { get; protected set; } = new DefaultLayout();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string Icon { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public void UpdateDisplayName()
|
||||
{
|
||||
|
|
|
@ -16,19 +16,13 @@ namespace Bootstrap.Admin.Components
|
|||
public NavigatorBarModel Model { get; set; } = new NavigatorBarModel("");
|
||||
|
||||
/// <summary>
|
||||
/// 侧边栏绑定 Model 改变事件
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<NavigatorBarModel> ModelChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
[CascadingParameter(Name = "Default")]
|
||||
public DefaultLayout RootLayout { get; protected set; } = new DefaultLayout();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public void UpdateDisplayName()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@inherits DefaultLayoutComponentBase
|
||||
|
||||
<CascadingValue Value=this Name="Default">
|
||||
<Header @ref="Header" Icon="@Model.Icon" Title="@Model.Title" IsAdmin=@IsAdmin UserName="@UserName" HomeUrl="@HomeUrl" DisplayName="@DisplayName" />
|
||||
<Header @ref="Header" Icon="@Model.Icon" Title="@Model.Title" />
|
||||
<SideBar @ref="SideBar" Model=@Model />
|
||||
@Body
|
||||
<Footer Text="@Model.Footer" IsDemo=@Model.IsDemo></Footer>
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
<header class="header">
|
||||
<div class="bg"></div>
|
||||
<div class="d-flex align-items-center">
|
||||
<a id="navbar" href="@HomeUrl" class="sidebar-toggle-box">
|
||||
<a id="navbar" href="@RootLayout.HomeUrl" class="sidebar-toggle-box">
|
||||
<i class="fa fa-bars"></i>
|
||||
<span id="websiteTitle">@Title</span>
|
||||
</a>
|
||||
<div class="nav">
|
||||
@if (IsAdmin)
|
||||
@if (@RootLayout.IsAdmin)
|
||||
{
|
||||
<!-- tasks start -->
|
||||
<div class="dropdown">
|
||||
|
@ -103,7 +103,7 @@
|
|||
<img src="@Icon.ToBlazorLink()">
|
||||
<div class="flex-fill">
|
||||
<div class="username text-truncate">@RootLayout.DisplayName</div>
|
||||
<div>登录名:@UserName</div>
|
||||
<div>登录名:@RootLayout.UserName</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
z-index: 9999 !important;
|
||||
}
|
||||
|
||||
.userinfo .username {
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
.nav-link-bar {
|
||||
border: 1px solid #dee2e6;
|
||||
border-top-left-radius: 0.25rem;
|
||||
|
@ -69,6 +73,7 @@ nav .dropdown .nav-link-close.dropdown-toggle:after {
|
|||
|
||||
.table th, .table td {
|
||||
padding: 0.5rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.table .btn.btn-sm {
|
||||
|
|
Loading…
Reference in New Issue