feat: Blazor 网站设置增加开启关闭演示模式开关

This commit is contained in:
Argo Zhang 2020-02-23 14:39:06 +08:00
parent 31d4c3d38e
commit feb1b3b90c
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
2 changed files with 51 additions and 0 deletions

View File

@ -253,6 +253,26 @@
</div>
</div>
</ConditionComponent>
<div class="card" asp-auth="demo">
<div class="card-header">演示系统设置</div>
<div class="card-body">
<div class="form-inline">
<div class="row">
<div class="form-group col-6">
<label class="control-label" data-toggle="lgbinfo" data-content="开启此功能网站切换至演示系统">演示系统</label>
<Toggle @bind-Value="@Model.EnableDemo" OnText="开启" OffText="关闭"></Toggle>
</div>
<div class="form-group col-6">
<label class="control-label" for="authKey">授权码</label>
<input type="password" autocomplete="off" class="form-control" @bind-value="@Model.AuthKey" />
</div>
</div>
</div>
<div class="modal-footer text-right">
<button class="btn btn-secondary" type="button" @onclick="SaveSystemModel"><i class="fa fa-save"></i><span>保存</span></button>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<span>网站缓存</span>

View File

@ -41,6 +41,12 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
/// </summary>
protected Toast? Toast { get; set; }
/// <summary>
/// NavigationManager 实例
/// </summary>
[Inject]
public NavigationManager? NavigationManager { get; set; }
/// <summary>
/// 显示提示信息
/// </summary>
@ -88,6 +94,7 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
Model.TraceLog = DictHelper.RetrieveAccessLogPeriod();
Model.CookiePeriod = DictHelper.RetrieveCookieExpiresPeriod();
Model.IPCachePeriod = DictHelper.RetrieveLocaleIPSvrCachePeriod();
Model.EnableDemo = DictHelper.RetrieveSystemModel();
}
/// <summary>
@ -216,6 +223,20 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
ShowMessage("保存日志缓存设置", ret);
}
/// <summary>
/// 保存网站是否为演示模式
/// </summary>
protected async System.Threading.Tasks.Task SaveSystemModel()
{
var ret = DictHelper.UpdateSystemModel(Model.EnableDemo, Model.AuthKey);
ShowMessage("保存演示系统设置", ret);
if (ret)
{
await System.Threading.Tasks.Task.Delay(500);
NavigationManager?.NavigateTo($"{RootLayout?.HomeUrl}/Admin/Settings", true);
}
}
/// <summary>
/// 网站设置编辑模型实体类
/// </summary>
@ -325,6 +346,16 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
/// IP请求缓存时长
/// </summary>
public int IPCachePeriod { get; set; }
/// <summary>
/// 获得/设置 授权码
/// </summary>
public string AuthKey { get; set; } = "";
/// <summary>
/// 获得 系统是否为演示模式
/// </summary>
public bool EnableDemo { get; set; }
}
}
}