feat: 网站设置增加缓存时长设置
This commit is contained in:
parent
fb10318b29
commit
4041a2d4f8
|
@ -22,7 +22,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="values"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ButtonAuthorize(Url = "~/Admin/Settings", Auth = "saveTitle,saveFooter,saveTheme,saveUISettings,loginSettings,lockScreen,defaultApp,blazor,iplocate")]
|
||||
[ButtonAuthorize(Url = "~/Admin/Settings", Auth = "saveTitle,saveFooter,saveTheme,saveUISettings,loginSettings,lockScreen,defaultApp,blazor,iplocate,logSettings")]
|
||||
public bool Post([FromBody]IEnumerable<BootstrapDict> values) => DictHelper.SaveUISettings(values);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -21,6 +21,12 @@ namespace Bootstrap.Admin.Models
|
|||
DefaultApp = DictHelper.RetrieveDefaultApp();
|
||||
IPLocators = DictHelper.RetireveLocators();
|
||||
IPLocatorSvr = DictHelper.RetrieveLocaleIPSvr();
|
||||
ErrorLogPeriod = DictHelper.RetrieveExceptionsLogPeriod();
|
||||
OpLog = DictHelper.RetrieveLogsPeriod();
|
||||
LogLog = DictHelper.RetrieveLoginLogsPeriod();
|
||||
TraceLog = DictHelper.RetrieveAccessLogPeriod();
|
||||
CookiePeriod = DictHelper.RetrieveCookieExpiresPeriod();
|
||||
IPCachePeriod = DictHelper.RetrieveLocaleIPSvrCachePeriod();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -31,13 +37,11 @@ namespace Bootstrap.Admin.Models
|
|||
/// <summary>
|
||||
/// 获得 地理位置信息集合
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public IEnumerable<BootstrapDict> IPLocators { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得 数据库中配置的地理位置信息接口
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string IPLocatorSvr { get; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -49,5 +53,35 @@ namespace Bootstrap.Admin.Models
|
|||
/// 获得 是否开启自动锁屏
|
||||
/// </summary>
|
||||
public bool DefaultApp { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 程序异常日志保留时长
|
||||
/// </summary>
|
||||
public int ErrorLogPeriod { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作日志保留时长
|
||||
/// </summary>
|
||||
public int OpLog { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录日志保留时长
|
||||
/// </summary>
|
||||
public int LogLog { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问日志保留时长
|
||||
/// </summary>
|
||||
public int TraceLog { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Cookie保留时长
|
||||
/// </summary>
|
||||
public int CookiePeriod { get; }
|
||||
|
||||
/// <summary>
|
||||
/// IP请求缓存时长
|
||||
/// </summary>
|
||||
public int IPCachePeriod { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,6 +202,45 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" asp-auth="logSettings">
|
||||
<div class="card-header">日志缓存设置</div>
|
||||
<div class="card-body">
|
||||
<div class="alert alert-danger" role="alert" asp-condition="@Model.IsDemo">
|
||||
<span>演示系统禁止更改日志缓存设置</span>
|
||||
</div>
|
||||
<div class="form-inline">
|
||||
<div class="row">
|
||||
<div class="form-group col-6">
|
||||
<label class="control-label" for="appErrorLog">异常日志(月)</label>
|
||||
<input id="appErrorLog" type="number" class="form-control" min="1" value="@Model.ErrorLogPeriod" />
|
||||
</div>
|
||||
<div class="form-group col-6">
|
||||
<label class="control-label" for="opLog">操作日志(月)</label>
|
||||
<input id="opLog" type="number" class="form-control" min="1" value="@Model.OpLog" />
|
||||
</div>
|
||||
<div class="form-group col-6">
|
||||
<label class="control-label" for="logLog">登录日志(月)</label>
|
||||
<input id="logLog" type="number" class="form-control" min="1" value="@Model.LogLog" />
|
||||
</div>
|
||||
<div class="form-group col-6">
|
||||
<label class="control-label" for="traceLog">访问日志(月)</label>
|
||||
<input id="traceLog" type="number" class="form-control" min="1" value="@Model.TraceLog" />
|
||||
</div>
|
||||
<div class="form-group col-6">
|
||||
<label class="control-label" for="cookiePeriod">Cookie(天)</label>
|
||||
<input id="cookiePeriod" type="number" class="form-control" min="1" value="@Model.CookiePeriod" />
|
||||
</div>
|
||||
<div class="form-group col-6">
|
||||
<label class="control-label" for="ipCachePeriod">IP 缓存(分)</label>
|
||||
<input id="ipCachePeriod" type="number" class="form-control" min="1" value="@Model.IPCachePeriod" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer text-right" asp-condition="@(!Model.IsDemo)">
|
||||
<button data-method="saveLogPeriod" class="btn btn-secondary" type="button"><i class="fa fa-save"></i><span>保存</span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="d-flex align-items-center">
|
||||
|
|
|
@ -110,6 +110,28 @@ $(function () {
|
|||
url: Settings.url, data: [{ name: 'IPLocator', code: iplocator }], title: '保存地理位置服务设置', method: "post"
|
||||
});
|
||||
break;
|
||||
case 'saveLogPeriod':
|
||||
var errLog = $('#appErrorLog').val();
|
||||
var opLog = $('#opLog').val();
|
||||
var logLog = $('#logLog').val();
|
||||
var traceLog = $('#traceLog').val();
|
||||
var cookiePeriod = $('#cookiePeriod').val();
|
||||
var ipCachePeriod = $('#ipCachePeriod').val();
|
||||
$.bc({
|
||||
url: Settings.url, data: [
|
||||
{ name: 'ErrLog', code: errLog },
|
||||
{ name: 'OpLog', code: opLog },
|
||||
{ name: 'LogLog', code: logLog },
|
||||
{ name: 'TraceLog', code: traceLog },
|
||||
{ name: 'CookiePeriod', code: cookiePeriod },
|
||||
{ name: 'IPCachePeriod', code: ipCachePeriod }
|
||||
], title: '保存日志缓存设置', method: "post",
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
window.setTimeout(function () { window.location.reload(true); }, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -136,7 +136,13 @@ namespace Bootstrap.DataAccess
|
|||
["AutoLockPeriod"] = "自动锁屏时长",
|
||||
["DefaultApp"] = "默认应用程序",
|
||||
["Blazor"] = "Blazor",
|
||||
["IPLocator"] = "IP地理位置接口"
|
||||
["IPLocator"] = "IP地理位置接口",
|
||||
["ErrLog"] = "程序异常保留时长",
|
||||
["OpLog"] = "操作日志保留时长",
|
||||
["LogLog"] = "登录日志保留时长",
|
||||
["TraceLog"] = "访问日志保留时长",
|
||||
["CookiePeriod"] = "Cookie保留时长",
|
||||
["IPCachePeriod"] = "IP请求缓存时长"
|
||||
};
|
||||
var ret = DictHelper.SaveSettings(items.Where(i => cache.Any(c => c.Key == i.Name)).Select(i => new BootstrapDict()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue