diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs index 7a572d10..8ebe82dc 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Settings.razor.cs @@ -1,5 +1,4 @@ using BootstrapAdmin.DataAccess.Models; -using BootstrapAdmin.Web.Components; using BootstrapAdmin.Web.Core; using BootstrapAdmin.Web.Extensions; using Microsoft.AspNetCore.Components.Forms; @@ -29,20 +28,13 @@ public partial class Settings [NotNull] private IDict? DictService { get; set; } - [Inject] - [NotNull] - private IUser? UserService { get; set; } - [Inject] [NotNull] private ToastService? ToastService { get; set; } - [Inject] + [CascadingParameter] [NotNull] - private DialogService? DialogService { get; set; } - - [NotNull] - private DialogOption? Option { get; set; } + private Layout? Layout { get; set; } /// /// @@ -100,12 +92,14 @@ public partial class Settings private async Task OnSaveTitle(EditContext context) { var ret = DictService.SaveWebTitle(AppInfo.Title); + await RenderLayout("title"); await ShowToast(ret, "网站标题"); } private async Task OnSaveFooter(EditContext context) { - var ret = DictService.SaveWebTitle(AppInfo.Title); + var ret = DictService.SaveWebFooter(AppInfo.Footer); + await RenderLayout("footer"); await ShowToast(ret, "网站页脚"); } @@ -179,4 +173,6 @@ public partial class Settings await ShowToast(ret, "日志缓存"); } + + private Task RenderLayout(string key) => Layout.OnUpdate(key); } diff --git a/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor b/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor index b9a7bc38..407c8d2a 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor +++ b/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor @@ -3,7 +3,7 @@ + UseTabSet="true" TabDefaultUrl="/Admin/Index" Update="Update">
Bootstrap of Blazor diff --git a/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs index c007216a..088cadad 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs @@ -153,6 +153,23 @@ namespace BootstrapAdmin.Web.Shared logger.LogError(ex, "ErrorLogger"); } + /// + /// + /// + public Task Update(string key) + { + if (key == "title") + { + Title = DictsService.GetWebTitle(); + } + else if (key == "footer") + { + Footer = DictsService.GetWebFooter(); + } + StateHasChanged(); + return Task.CompletedTask; + } + private void Dispose(bool disposing) { if (disposing)