feat: 增加默认应用设置功能

This commit is contained in:
Argo-Tianyi 2022-01-12 12:13:05 +08:00
parent e25fecb164
commit 57537d50d3
7 changed files with 71 additions and 29 deletions

View File

@ -6,8 +6,10 @@
"src\\blazor\\admin\\BootstrapAdmin.DataAccess.PetaPoco\\BootstrapAdmin.DataAccess.PetaPoco.csproj", "src\\blazor\\admin\\BootstrapAdmin.DataAccess.PetaPoco\\BootstrapAdmin.DataAccess.PetaPoco.csproj",
"src\\blazor\\admin\\BootstrapAdmin.Web.Core\\BootstrapAdmin.Web.Core.csproj", "src\\blazor\\admin\\BootstrapAdmin.Web.Core\\BootstrapAdmin.Web.Core.csproj",
"src\\blazor\\admin\\BootstrapAdmin.Web\\BootstrapAdmin.Web.csproj", "src\\blazor\\admin\\BootstrapAdmin.Web\\BootstrapAdmin.Web.csproj",
"src\\mvc\\admin\\Bootstrap.Admin\\Bootstrap.Admin.csproj", "src\\blazor\\client\\BootstrapClient.DataAccess\\BootstrapClient.Web.DataAccess.csproj",
"src\\mvc\\admin\\Bootstrap.DataAccess\\Bootstrap.DataAccess.csproj" "src\\blazor\\client\\BootstrapClient.Shared\\BootstrapClient.Web.Shared.csproj",
"src\\blazor\\client\\BootstrapClient.Web\\BootstrapClient.Web.csproj",
"test\\UnitTest\\UnitTest.csproj"
] ]
} }
} }

View File

@ -26,7 +26,7 @@ public class AppInfo
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Display(Name = "登录地址")] [Display(Name = "登录首页")]
[NotNull] [NotNull]
public string? Login { get; set; } public string? Login { get; set; }
@ -40,9 +40,16 @@ public class AppInfo
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Display(Name = "网站主题")]
[NotNull] [NotNull]
public string? Theme { get; set; } public string? Theme { get; set; }
/// <summary>
/// 是否开启默认应用功能
/// </summary>
[Display(Name = "默认应用")]
public bool EnableDefaultApp { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<ItemGroup> <ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="6.2.7-beta02" /> <PackageReference Include="BootstrapBlazor" Version="6.2.7-beta03" />
<PackageReference Include="Longbow.Security.Cryptography" Version="5.2.0" /> <PackageReference Include="Longbow.Security.Cryptography" Version="5.2.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.1" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.1" />
<PackageReference Include="PetaPoco.Extensions" Version="5.2.0" /> <PackageReference Include="PetaPoco.Extensions" Version="5.2.0" />

View File

@ -117,9 +117,28 @@ class DictService : BaseDatabase, IDict
/// <summary> /// <summary>
/// 保存当前网站是否为演示系统 /// 保存当前网站是否为演示系统
/// </summary> /// </summary>
/// <param name="isDemo"></param> /// <param name="enable"></param>
/// <returns></returns> /// <returns></returns>
public bool SaveDemo(bool isDemo) => Database.Execute("Update Dicts Set Code = @0 Where Category = @1 and Name = @2 and Define = @3", isDemo ? "1" : "0", "网站设置", "演示系统", EnumDictDefine.System) == 1; public bool SaveDemo(bool enable) => SaveDict(new Dict
{
Category = "网站设置",
Name = "演示系统",
Code = enable ? "1" : "0",
Define = EnumDictDefine.System
});
/// <summary>
///
/// </summary>
/// <param name="enable"></param>
/// <returns></returns>
public bool SavDefaultApp(bool enable) => SaveDict(new Dict
{
Category = "网站设置",
Name = "默认应用程序",
Code = enable ? "1" : "0",
Define = EnumDictDefine.System
});
/// <summary> /// <summary>
/// ///
@ -127,7 +146,13 @@ class DictService : BaseDatabase, IDict
/// <param name="enable"></param> /// <param name="enable"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public bool SaveHealthCheck(bool enable = true) => Database.Execute("Update Dicts Set Code = @0 Where Category = @1 and Name = @2 and Define = @3", enable ? "1" : "0", "网站设置", "健康检查", EnumDictDefine.System.ToString()) == 1; public bool SaveHealthCheck(bool enable = true) => SaveDict(new Dict
{
Category = "网站设置",
Name = "健康检查",
Code = enable ? "1" : "0",
Define = EnumDictDefine.System
});
/// <summary> /// <summary>
/// 获取当前网站 Cookie 保持时长 /// 获取当前网站 Cookie 保持时长

View File

@ -64,6 +64,13 @@ public interface IDict
/// <returns></returns> /// <returns></returns>
bool SaveDemo(bool isDemo); bool SaveDemo(bool isDemo);
/// <summary>
/// 保存是否开启默认应用设置
/// </summary>
/// <param name="enabled"></param>
/// <returns></returns>
bool SavDefaultApp(bool enabled);
/// <summary> /// <summary>
/// 保存健康检查 /// 保存健康检查
/// </summary> /// </summary>

View File

@ -47,22 +47,6 @@
</ValidateForm> </ValidateForm>
</AdminCard> </AdminCard>
<AdminCard HeaderText="后台管理地址设置" AuthorizeKey="SaveLogin">
<AdminAlert Text="此功能给前台网站拼接后台功能菜单时使用" Color="Color.Info" />
<ValidateForm OnValidSubmit="OnSaveAuthUrl" Model="AppInfo">
<div class="row g-3 form-inline">
<div class="col-12 col-sm-6">
<BootstrapInput @bind-Value="@AppInfo.AuthUrl" Readonly="IsDemo" />
</div>
<Block Condition="!IsDemo">
<div class="col-12 col-sm-6 text-end">
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
</div>
</Block>
</div>
</ValidateForm>
</AdminCard>
<AdminCard HeaderText="网站样式设置" AuthorizeKey="SaveTheme"> <AdminCard HeaderText="网站样式设置" AuthorizeKey="SaveTheme">
<AdminAlert Color="Color.Info"> <AdminAlert Color="Color.Info">
<span>注意:本设置将覆盖 <b><TabLink Url="/Admin/Profiles" Text="个人中心" Icon="fa fa-fa">个人中心</TabLink></b> 中设置的网站样式覆盖本设置</span> <span>注意:本设置将覆盖 <b><TabLink Url="/Admin/Profiles" Text="个人中心" Icon="fa fa-fa">个人中心</TabLink></b> 中设置的网站样式覆盖本设置</span>
@ -80,7 +64,24 @@
</ValidateForm> </ValidateForm>
</AdminCard> </AdminCard>
<AdminCard HeaderText="默认应用设置" AuthorizeKey="DefaultApp">
<AdminAlert Text="开启本功能后登录后自动导航到第一个已授权前台应用" Color="Color.Info" />
<ValidateForm OnValidSubmit="OnSaveApp" Model="AppInfo">
<div class="row g-3 form-inline">
<div class="col-12 col-sm-6">
<Toggle @bind-Value="AppInfo.EnableDefaultApp" OnText="启用" OffText="关闭" />
</div>
<div class="col-12 col-sm-6 text-end">
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
</div>
</div>
</ValidateForm>
</AdminCard>
<AdminCard HeaderText="系统演示设置" AuthorizeKey="SaveDemo"> <AdminCard HeaderText="系统演示设置" AuthorizeKey="SaveDemo">
<AdminAlert Text="开启本功能后系统运行在演示模式下部分功能禁止操作" Color="Color.Info" />
<ValidateForm OnValidSubmit="OnSaveDemo" Model="AppInfo"> <ValidateForm OnValidSubmit="OnSaveDemo" Model="AppInfo">
<div class="row g-3 form-inline"> <div class="row g-3 form-inline">
<div class="col-12 col-sm-4"> <div class="col-12 col-sm-4">

View File

@ -83,12 +83,6 @@ public partial class Settings
await ShowToast(ret, "登录界面"); await ShowToast(ret, "登录界面");
} }
private async Task OnSaveAuthUrl(EditContext context)
{
var ret = DictService.SaveLogin(AppInfo.Login);
await ShowToast(ret, "授权后台地址");
}
private async Task OnSaveTheme(EditContext context) private async Task OnSaveTheme(EditContext context)
{ {
var ret = DictService.SaveLogin(AppInfo.Login); var ret = DictService.SaveLogin(AppInfo.Login);
@ -106,4 +100,10 @@ public partial class Settings
} }
await ShowToast(ret, "演示系统"); await ShowToast(ret, "演示系统");
} }
private async Task OnSaveApp(EditContext context)
{
var ret = DictService.SaveDemo(AppInfo.EnableDefaultApp);
await ShowToast(ret, "默认应用");
}
} }