feat: 网站设置触发 MainLayout 更新 UI
This commit is contained in:
parent
1ff9891331
commit
9d2c3dfdac
|
@ -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; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<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">
|
||||
UseTabSet="true" TabDefaultUrl="/Admin/Index" Update="Update">
|
||||
<Header>
|
||||
<span class="ms-3 flex-fill">Bootstrap of Blazor</span>
|
||||
<Logout ImageUrl="@Icon" DisplayName="@DisplayName" UserName="@UserName">
|
||||
|
|
|
@ -153,6 +153,23 @@ namespace BootstrapAdmin.Web.Shared
|
|||
logger.LogError(ex, "ErrorLogger");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue