refactor: 个人中心

This commit is contained in:
Argo Zhang 2019-12-13 14:46:57 +08:00
parent 3b0d371ec1
commit 902c9435a6
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
4 changed files with 14 additions and 11 deletions

View File

@ -108,8 +108,8 @@ namespace Bootstrap.Admin.Components
public void OnDisplayNameChanged(string displayName)
{
DisplayName = displayName;
Header?.UpdateDisplayName();
SideBar?.UpdateDisplayName();
Header?.UpdateState();
SideBar?.UpdateState();
}
/// <summary>

View File

@ -29,7 +29,7 @@ namespace Bootstrap.Admin.Components
/// <summary>
///
/// </summary>
public void UpdateDisplayName()
public void UpdateState()
{
StateHasChanged();
}

View File

@ -24,7 +24,7 @@ namespace Bootstrap.Admin.Components
/// <summary>
///
/// </summary>
public void UpdateDisplayName()
public void UpdateState()
{
StateHasChanged();
}

View File

@ -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);
}
}
}