feat: 增加网站功能设置

This commit is contained in:
zhangpeihang 2022-01-14 09:49:09 +08:00
parent 16ed058850
commit 7b2b7490fa
6 changed files with 140 additions and 1 deletions

View File

@ -56,6 +56,30 @@ public class AppInfo
[Display(Name = "系统演示")]
public bool IsDemo { get; set; }
/// <summary>
///
/// </summary>
[Display(Name = "侧边栏设置")]
public bool SiderbarSetting { get; set; }
/// <summary>
///
/// </summary>
[Display(Name = "标题设置")]
public bool TitleSetting { get; set; }
/// <summary>
///
/// </summary>
[Display(Name = "固定表头")]
public bool FixHeaderSetting { get; set; }
/// <summary>
///
/// </summary>
[Display(Name = "健康检查")]
public bool HealthCheckSetting { get; set; }
/// <summary>
///
/// </summary>

View File

@ -257,4 +257,36 @@ class DictService : IDict
}
return url;
}
public bool GetAppSiderbar()
{
var dicts = GetAll();
return dicts.FirstOrDefault(s => s.Category == "网站设置" && s.Name == "侧边栏状态" && s.Define == EnumDictDefine.System)?.Code == "1" ? true : false;
}
public bool SaveAppSiderbar(bool value) => SaveDict(new Dict { Category = "网站设置", Name = "侧边栏状态", Code = value ? "1" : "0" });
public bool GetAppTitle()
{
var dicts = GetAll();
return dicts.FirstOrDefault(s => s.Category == "网站设置" && s.Name == "卡片标题状态" && s.Define == EnumDictDefine.System)?.Code == "1" ? true : false;
}
public bool SaveAppTitle(bool value) => SaveDict(new Dict { Category = "网站设置", Name = "卡片标题状态", Code = value ? "1" : "0" });
public bool GetAppFixHeader()
{
var dicts = GetAll();
return dicts.FirstOrDefault(s => s.Category == "网站设置" && s.Name == "固定表头" && s.Define == EnumDictDefine.System)?.Code == "1" ? true : false;
}
public bool SaveAppFixHeader(bool value) => SaveDict(new Dict { Category = "网站设置", Name = "固定表头", Code = value ? "1" : "0" });
public bool GetAppHealthCheck()
{
var dicts = GetAll();
return dicts.FirstOrDefault(s => s.Category == "网站设置" && s.Name == "健康检查" && s.Define == EnumDictDefine.System)?.Code == "1" ? true : false;
}
public bool SaveAppHealthCheck(bool value) => SaveDict(new Dict { Category = "网站设置", Name = "健康检查", Code = value ? "1" : "0" });
}

View File

@ -168,4 +168,52 @@ public interface IDict
/// </summary>
/// <returns></returns>
bool GetEnableDefaultApp();
/// <summary>
/// 是否开启侧边栏设置
/// </summary>
/// <returns></returns>
bool GetAppSiderbar();
/// <summary>
/// 保存侧边栏设置
/// </summary>
/// <returns></returns>
bool SaveAppSiderbar(bool value);
/// <summary>
/// 是否开启标题设置
/// </summary>
/// <returns></returns>
bool GetAppTitle();
/// <summary>
/// 保存标题设置
/// </summary>
/// <returns></returns>
bool SaveAppTitle(bool value);
/// <summary>
/// 是否开启固定表头设置
/// </summary>
/// <returns></returns>
bool GetAppFixHeader();
/// <summary>
/// 保存固定表头设置
/// </summary>
/// <returns></returns>
bool SaveAppFixHeader(bool value);
/// <summary>
/// 是否开启健康检查设置
/// </summary>
/// <returns></returns>
bool GetAppHealthCheck();
/// <summary>
/// 保存健康检查设置
/// </summary>
/// <returns></returns>
bool SaveAppHealthCheck(bool value);
}

View File

@ -64,6 +64,28 @@
</ValidateForm>
</AdminCard>
<AdminCard HeaderText="网站功能设置" AuthorizeKey="SaveAppFeatures">
<ValidateForm OnValidSubmit="OnSaveAppFeatures" Model="AppInfo">
<div class="row g-3 form-inline">
<div class="col-6 col-sm-6">
<Toggle @bind-Value="AppInfo.SiderbarSetting" OnText="启用" OffText="关闭"></Toggle>
</div>
<div class="col-6 col-sm-6">
<Toggle @bind-Value="AppInfo.TitleSetting" OnText="启用" OffText="关闭"></Toggle>
</div>
<div class="col-6 col-sm-6">
<Toggle @bind-Value="AppInfo.FixHeaderSetting" OnText="启用" OffText="关闭"></Toggle>
</div>
<div class="col-6 col-sm-6">
<Toggle @bind-Value="AppInfo.HealthCheckSetting" OnText="启用" OffText="关闭"></Toggle>
</div>
<div class="col-12 col-sm-12 text-end">
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
</div>
</div>
</ValidateForm>
</AdminCard>
<AdminCard HeaderText="默认应用设置" AuthorizeKey="DefaultApp">
<AdminAlert Text="开启本功能后登录成功时自动导航到第一个已授权前台应用" Color="Color.Info" />

View File

@ -49,7 +49,11 @@ public partial class Settings
AuthCode = "123789",
Title = DictService.GetWebTitle(),
Footer = DictService.GetWebFooter(),
Login = DictService.GetCurrentLogin()
Login = DictService.GetCurrentLogin(),
SiderbarSetting = DictService.GetAppSiderbar(),
TitleSetting = DictService.GetAppTitle(),
FixHeaderSetting = DictService.GetAppFixHeader(),
HealthCheckSetting = DictService.GetAppHealthCheck(),
};
}
@ -106,4 +110,13 @@ public partial class Settings
var ret = DictService.SaveDemo(AppInfo.EnableDefaultApp);
await ShowToast(ret, "默认应用");
}
private async Task OnSaveAppFeatures(EditContext context)
{
var ret = DictService.SaveAppSiderbar(AppInfo.SiderbarSetting);
DictService.SaveAppTitle(AppInfo.TitleSetting);
DictService.SaveAppFixHeader(AppInfo.FixHeaderSetting);
DictService.SaveAppHealthCheck(AppInfo.HealthCheckSetting);
await ShowToast(ret, "网站功能");
}
}