diff --git a/src/admin/Bootstrap.Admin/Components/DefaultLayoutComponentBase.cs b/src/admin/Bootstrap.Admin/Components/DefaultLayoutComponentBase.cs index 0a67ca09..d34b2749 100644 --- a/src/admin/Bootstrap.Admin/Components/DefaultLayoutComponentBase.cs +++ b/src/admin/Bootstrap.Admin/Components/DefaultLayoutComponentBase.cs @@ -108,8 +108,8 @@ namespace Bootstrap.Admin.Components public void OnDisplayNameChanged(string displayName) { DisplayName = displayName; - Header?.UpdateDisplayName(); - SideBar?.UpdateDisplayName(); + Header?.UpdateState(); + SideBar?.UpdateState(); } /// diff --git a/src/admin/Bootstrap.Admin/Components/HeaderBase.cs b/src/admin/Bootstrap.Admin/Components/HeaderBase.cs index 639c753b..9ba2537d 100644 --- a/src/admin/Bootstrap.Admin/Components/HeaderBase.cs +++ b/src/admin/Bootstrap.Admin/Components/HeaderBase.cs @@ -29,7 +29,7 @@ namespace Bootstrap.Admin.Components /// /// /// - public void UpdateDisplayName() + public void UpdateState() { StateHasChanged(); } diff --git a/src/admin/Bootstrap.Admin/Components/SideBarBase.cs b/src/admin/Bootstrap.Admin/Components/SideBarBase.cs index e0ae44d0..fc01c9ad 100644 --- a/src/admin/Bootstrap.Admin/Components/SideBarBase.cs +++ b/src/admin/Bootstrap.Admin/Components/SideBarBase.cs @@ -24,7 +24,7 @@ namespace Bootstrap.Admin.Components /// /// /// - public void UpdateDisplayName() + public void UpdateState() { StateHasChanged(); } diff --git a/src/admin/Bootstrap.Admin/Pages/Admin/Profiles.razor b/src/admin/Bootstrap.Admin/Pages/Admin/Profiles.razor index cfc286bf..537662e9 100644 --- a/src/admin/Bootstrap.Admin/Pages/Admin/Profiles.razor +++ b/src/admin/Bootstrap.Admin/Pages/Admin/Profiles.razor @@ -1,7 +1,7 @@ 
基本资料
- @if (!(Model?.IsDemo ?? false)) + @if (IsDemo) {
- @if (!(Model?.IsDemo ?? false)) + @if (!IsDemo) {
[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); } } }