feat: 增加更新 DisplayName 逻辑
This commit is contained in:
parent
f748b69dfe
commit
ce9cc849d4
|
@ -56,6 +56,10 @@ public partial class Profiles
|
|||
[NotNull]
|
||||
private string? DefaultLogoFolder { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
[NotNull]
|
||||
private Layout? Layout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -109,8 +113,13 @@ public partial class Profiles
|
|||
|
||||
private async Task OnSaveDisplayName(EditContext context)
|
||||
{
|
||||
var ret = UserService.SaveDisplayName(CurrentUser.DisplayName, CurrentUser.UserName);
|
||||
var ret = UserService.SaveDisplayName(CurrentUser.UserName, CurrentUser.DisplayName);
|
||||
await ShowToast(ret, "显示名称");
|
||||
if (ret)
|
||||
{
|
||||
AppContext.DisplayName = CurrentUser.DisplayName;
|
||||
await RenderLayout("displayName");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnSavePassword(EditContext context)
|
||||
|
@ -177,4 +186,12 @@ public partial class Profiles
|
|||
await ShowToast(ret, "用户头像", "删除");
|
||||
return ret;
|
||||
}
|
||||
|
||||
private async Task RenderLayout(string key)
|
||||
{
|
||||
if (Layout.OnUpdateAsync != null)
|
||||
{
|
||||
await Layout.OnUpdateAsync(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,9 +180,9 @@ public partial class Settings
|
|||
|
||||
private async Task RenderLayout(string key)
|
||||
{
|
||||
if (Layout.OnUpdate != null)
|
||||
if (Layout.OnUpdateAsync != null)
|
||||
{
|
||||
await Layout.OnUpdate(key);
|
||||
await Layout.OnUpdateAsync(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<Layout SideWidth="0" IsPage="true" IsFullSide="true" IsFixedHeader="true"
|
||||
ShowFooter="true" ShowGotoTop="true" ShowCollapseBar="true" Menus="@MenuItems"
|
||||
OnAuthorizing="@OnAuthorizing" OnErrorHandleAsync="OnErrorHandleAsync"
|
||||
UseTabSet="true" TabDefaultUrl="/Admin/Index" OnUpdate="OnUpdate">
|
||||
UseTabSet="true" TabDefaultUrl="/Admin/Index" OnUpdateAsync="OnUpdateAsync">
|
||||
<Header>
|
||||
<span class="ms-3 flex-fill">Bootstrap of Blazor</span>
|
||||
<Logout ImageUrl="@Icon" DisplayName="@DisplayName" UserName="@UserName">
|
||||
<Logout ImageUrl="@Icon" DisplayName="@Context.DisplayName" UserName="@UserName">
|
||||
<LinkTemplate>
|
||||
<a href="/Admin/Profiles"><i class="fa fa-suitcase"></i>个人中心</a>
|
||||
<a href="/Admin/Index"><i class="fa fa-cog"></i>设置</a>
|
||||
|
@ -26,7 +26,7 @@
|
|||
<div class="layout-user">
|
||||
<img class="layout-avatar" src="@Icon">
|
||||
<div class="layout-title">
|
||||
<span>@DisplayName</span>
|
||||
<span>@Context.DisplayName</span>
|
||||
</div>
|
||||
<div class="layout-user-state"></div>
|
||||
</div>
|
||||
|
|
|
@ -74,8 +74,6 @@ namespace BootstrapAdmin.Web.Shared
|
|||
|
||||
private string? Footer { get; set; }
|
||||
|
||||
private string? DisplayName { get; set; }
|
||||
|
||||
private string? UserName { get; set; }
|
||||
|
||||
private bool Lock { get; set; }
|
||||
|
@ -133,9 +131,8 @@ namespace BootstrapAdmin.Web.Shared
|
|||
if (!string.IsNullOrEmpty(UserName))
|
||||
{
|
||||
var user = UsersService.GetUserByUserName(UserName);
|
||||
DisplayName = user?.DisplayName ?? "未注册账户";
|
||||
Context.UserName = UserName;
|
||||
Context.DisplayName = DisplayName;
|
||||
Context.DisplayName = user?.DisplayName ?? "未注册账户"; ;
|
||||
Icon = string.IsNullOrEmpty(user?.Icon) ? "/images/uploader/default.jpg" : GetIcon(user.Icon);
|
||||
|
||||
MenuItems = NavigationsService.GetAllMenus(UserName).ToMenus();
|
||||
|
@ -161,7 +158,7 @@ namespace BootstrapAdmin.Web.Shared
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Task OnUpdate(string key)
|
||||
public Task OnUpdateAsync(string key)
|
||||
{
|
||||
if (key == "title")
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue