feat: 网站设置触发 MainLayout 更新 UI
This commit is contained in:
parent
1ff9891331
commit
9d2c3dfdac
|
@ -1,5 +1,4 @@
|
||||||
using BootstrapAdmin.DataAccess.Models;
|
using BootstrapAdmin.DataAccess.Models;
|
||||||
using BootstrapAdmin.Web.Components;
|
|
||||||
using BootstrapAdmin.Web.Core;
|
using BootstrapAdmin.Web.Core;
|
||||||
using BootstrapAdmin.Web.Extensions;
|
using BootstrapAdmin.Web.Extensions;
|
||||||
using Microsoft.AspNetCore.Components.Forms;
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
|
@ -29,20 +28,13 @@ public partial class Settings
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private IDict? DictService { get; set; }
|
private IDict? DictService { get; set; }
|
||||||
|
|
||||||
[Inject]
|
|
||||||
[NotNull]
|
|
||||||
private IUser? UserService { get; set; }
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private ToastService? ToastService { get; set; }
|
private ToastService? ToastService { get; set; }
|
||||||
|
|
||||||
[Inject]
|
[CascadingParameter]
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private DialogService? DialogService { get; set; }
|
private Layout? Layout { get; set; }
|
||||||
|
|
||||||
[NotNull]
|
|
||||||
private DialogOption? Option { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
@ -100,12 +92,14 @@ public partial class Settings
|
||||||
private async Task OnSaveTitle(EditContext context)
|
private async Task OnSaveTitle(EditContext context)
|
||||||
{
|
{
|
||||||
var ret = DictService.SaveWebTitle(AppInfo.Title);
|
var ret = DictService.SaveWebTitle(AppInfo.Title);
|
||||||
|
await RenderLayout("title");
|
||||||
await ShowToast(ret, "网站标题");
|
await ShowToast(ret, "网站标题");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnSaveFooter(EditContext context)
|
private async Task OnSaveFooter(EditContext context)
|
||||||
{
|
{
|
||||||
var ret = DictService.SaveWebTitle(AppInfo.Title);
|
var ret = DictService.SaveWebFooter(AppInfo.Footer);
|
||||||
|
await RenderLayout("footer");
|
||||||
await ShowToast(ret, "网站页脚");
|
await ShowToast(ret, "网站页脚");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,4 +173,6 @@ public partial class Settings
|
||||||
|
|
||||||
await ShowToast(ret, "日志缓存");
|
await ShowToast(ret, "日志缓存");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Task RenderLayout(string key) => Layout.OnUpdate(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<Layout SideWidth="0" IsPage="true" IsFullSide="true" IsFixedHeader="true"
|
<Layout SideWidth="0" IsPage="true" IsFullSide="true" IsFixedHeader="true"
|
||||||
ShowFooter="true" ShowGotoTop="true" ShowCollapseBar="true" Menus="@MenuItems"
|
ShowFooter="true" ShowGotoTop="true" ShowCollapseBar="true" Menus="@MenuItems"
|
||||||
OnAuthorizing="@OnAuthorizing" OnErrorHandleAsync="OnErrorHandleAsync"
|
OnAuthorizing="@OnAuthorizing" OnErrorHandleAsync="OnErrorHandleAsync"
|
||||||
UseTabSet="true" TabDefaultUrl="/Admin/Index">
|
UseTabSet="true" TabDefaultUrl="/Admin/Index" Update="Update">
|
||||||
<Header>
|
<Header>
|
||||||
<span class="ms-3 flex-fill">Bootstrap of Blazor</span>
|
<span class="ms-3 flex-fill">Bootstrap of Blazor</span>
|
||||||
<Logout ImageUrl="@Icon" DisplayName="@DisplayName" UserName="@UserName">
|
<Logout ImageUrl="@Icon" DisplayName="@DisplayName" UserName="@UserName">
|
||||||
|
|
|
@ -153,6 +153,23 @@ namespace BootstrapAdmin.Web.Shared
|
||||||
logger.LogError(ex, "ErrorLogger");
|
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)
|
private void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
|
Loading…
Reference in New Issue