feat: Blazor 网站页脚保存成功

This commit is contained in:
Argo Zhang 2020-02-15 16:59:11 +08:00
parent 488ac6be60
commit 5d141b3b78
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
6 changed files with 48 additions and 3 deletions

View File

@ -87,6 +87,11 @@ namespace Bootstrap.Admin.Pages.Components
/// </summary>
protected SideBar? SideBar { get; set; }
/// <summary>
/// Footer 组件引用实例
/// </summary>
protected Footer? Footer { get; set; }
/// <summary>
/// OnInitializedAsync 方法
/// </summary>
@ -128,6 +133,7 @@ namespace Bootstrap.Admin.Pages.Components
Model = new NavigatorBarModel(UserName, RequestUrl.ToMvcMenuUrl());
DisplayName = Model.DisplayName;
WebTitle = Model.Title;
WebFooter = Model.Footer;
if (HomeUrl.StartsWith("/")) HomeUrl = NavigationManager.ToBlazorLink(HomeUrl);
}
}
@ -152,6 +158,18 @@ namespace Bootstrap.Admin.Pages.Components
SideBar?.WebTitleChanged.InvokeAsync(title);
}
/// <summary>
/// 获得/设置 网站页脚文字
/// </summary>
/// <value></value>
public string WebFooter { get; set; } = "";
/// <summary>
/// 网站页脚文字变化是触发此方法
/// </summary>
/// <param name="text"></param>
public void OnWebFooterChanged(string text) => Footer?.TextChanged.InvokeAsync(text);
/// <summary>
/// OnAfterRender 方法
/// </summary>

View File

@ -4,5 +4,5 @@
<Header @ref="Header" Icon="@Model.Icon" @bind-DisplayName="DisplayName" @bind-WebTitle="WebTitle"/>
<SideBar @ref="SideBar" Model=@Model @bind-DisplayName="DisplayName" @bind-WebTitle="WebTitle" />
@Body
<Footer Text="@Model.Footer" IsDemo=@Model.IsDemo></Footer>
<Footer @ref="Footer" IsDemo=@Model.IsDemo @bind-Text="WebFooter"></Footer>
</CascadingValue>

View File

@ -15,6 +15,9 @@
[Parameter]
public string Text { get; set; } = "未设置";
[Parameter]
public EventCallback<string> TextChanged { get; set; }
[Parameter]
public bool IsDemo { get; set; }
}

View File

@ -33,10 +33,10 @@
</ConditionComponent>
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" id="sysFoot" placeholder="请输入网站页脚50字以内" value="@Model.Footer" />
<input type="text" class="form-control" id="sysFoot" placeholder="请输入网站页脚50字以内" @bind-value="@Model.Footer" />
<ConditionComponent Inverse="true">
<div class="input-group-append">
<button class="btn btn-secondary" type="button">保存</button>
<button class="btn btn-secondary" type="button" @onclick="SaveWebFooter">保存</button>
</div>
</ConditionComponent>
</div>

View File

@ -170,6 +170,16 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
ShowMessage("保存网站标题", ret);
}
/// <summary>
/// 保存网站页脚
/// </summary>
protected void SaveWebFooter()
{
var ret = DictHelper.SaveWebFooter(Model.Footer);
RootLayout?.OnWebFooterChanged(Model.Footer);
ShowMessage("保存网站页脚", ret);
}
/// <summary>
/// 网站设置编辑模型实体类
/// </summary>

View File

@ -129,6 +129,20 @@ namespace Bootstrap.DataAccess
return ret;
}
/// <summary>
/// 保存网站页脚
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static bool SaveWebFooter(string code)
{
var ret = DictHelper.SaveSettings(new BootstrapDict[]
{
new BootstrapDict() { Category = "网站设置", Name = "网站页脚", Code = code }
});
return ret;
}
/// <summary>
/// 获取字典分类名称
/// </summary>