refactor: 个人中心
This commit is contained in:
parent
3b0d371ec1
commit
902c9435a6
|
@ -108,8 +108,8 @@ namespace Bootstrap.Admin.Components
|
|||
public void OnDisplayNameChanged(string displayName)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
Header?.UpdateDisplayName();
|
||||
SideBar?.UpdateDisplayName();
|
||||
Header?.UpdateState();
|
||||
SideBar?.UpdateState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Bootstrap.Admin.Components
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void UpdateDisplayName()
|
||||
public void UpdateState()
|
||||
{
|
||||
StateHasChanged();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Bootstrap.Admin.Components
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void UpdateDisplayName()
|
||||
public void UpdateState()
|
||||
{
|
||||
StateHasChanged();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="card" asp-auth="saveDisplayName">
|
||||
<div class="card-header">基本资料</div>
|
||||
<div class="card-body" data-toggle="LgbValidate" data-valid-button="#btnSaveDisplayName">
|
||||
@if (!(Model?.IsDemo ?? false))
|
||||
@if (IsDemo)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span>演示系统禁止更改管理员显示名称</span>
|
||||
|
@ -19,7 +19,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@if (!(Model?.IsDemo ?? false))
|
||||
@if (!IsDemo)
|
||||
{
|
||||
<div class="modal-footer">
|
||||
<button id="btnSaveDisplayName" data-method="user" class="btn btn-secondary" type="button" @onclick="SaveDisplayName"><i class="fa fa-save"></i><span>保存</span></button>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<div class="card" asp-auth="savePassword" asp-condition="!@Model?.External">
|
||||
<div class="card-header">修改密码</div>
|
||||
<div class="card-body" data-toggle="LgbValidate" data-valid-button="#btnSavePassword">
|
||||
@if (!(Model?.IsDemo ?? false))
|
||||
@if (IsDemo)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span>演示系统禁止更改管理员密码</span>
|
||||
|
@ -54,7 +54,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@if (!(Model?.IsDemo ?? false))
|
||||
@if (!IsDemo)
|
||||
{
|
||||
<div class="modal-footer">
|
||||
<button id="btnSavePassword" data-method="password" class="btn btn-secondary" type="button"><i class="fa fa-save"></i><span>保存</span></button>
|
||||
|
@ -121,16 +121,19 @@
|
|||
///
|
||||
/// </summary>
|
||||
[CascadingParameter(Name = "Default")]
|
||||
public DefaultLayout RootLayout { get; protected set; } = new DefaultLayout();
|
||||
public DefaultLayout? RootLayout { get; protected set; }
|
||||
|
||||
protected ProfilesModel? Model { get; set; }
|
||||
|
||||
protected string DisplayName { get; set; } = "";
|
||||
|
||||
protected bool IsDemo { get; set; } = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Model = new ProfilesModel(RootLayout.UserName);
|
||||
Model = new ProfilesModel(RootLayout?.UserName);
|
||||
DisplayName = Model.DisplayName;
|
||||
IsDemo = Model?.IsDemo ?? false;
|
||||
}
|
||||
|
||||
private void SaveDisplayName()
|
||||
|
@ -139,7 +142,7 @@
|
|||
{
|
||||
if (Bootstrap.DataAccess.UserHelper.SaveDisplayName(Model.UserName, DisplayName))
|
||||
{
|
||||
RootLayout.OnDisplayNameChanged(DisplayName);
|
||||
RootLayout?.OnDisplayNameChanged(DisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue