diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs index 9733fdd6..4df34cd8 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs @@ -22,7 +22,7 @@ namespace Bootstrap.Admin.Controllers.Api /// /// [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 values) => DictHelper.SaveUISettings(values); /// diff --git a/src/admin/Bootstrap.Admin/Models/SettingsModel.cs b/src/admin/Bootstrap.Admin/Models/SettingsModel.cs index 3e5d9327..005c9e9f 100644 --- a/src/admin/Bootstrap.Admin/Models/SettingsModel.cs +++ b/src/admin/Bootstrap.Admin/Models/SettingsModel.cs @@ -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(); } /// @@ -31,13 +37,11 @@ namespace Bootstrap.Admin.Models /// /// 获得 地理位置信息集合 /// - /// public IEnumerable IPLocators { get; } /// /// 获得 数据库中配置的地理位置信息接口 /// - /// public string IPLocatorSvr { get; } /// @@ -49,5 +53,35 @@ namespace Bootstrap.Admin.Models /// 获得 是否开启自动锁屏 /// public bool DefaultApp { get; } + + /// + /// 程序异常日志保留时长 + /// + public int ErrorLogPeriod { get; } + + /// + /// 操作日志保留时长 + /// + public int OpLog { get; } + + /// + /// 登录日志保留时长 + /// + public int LogLog { get; } + + /// + /// 访问日志保留时长 + /// + public int TraceLog { get; } + + /// + /// Cookie保留时长 + /// + public int CookiePeriod { get; } + + /// + /// IP请求缓存时长 + /// + public int IPCachePeriod { get; } } } diff --git a/src/admin/Bootstrap.Admin/Views/Admin/Settings.cshtml b/src/admin/Bootstrap.Admin/Views/Admin/Settings.cshtml index 40f261b5..2724e6fc 100644 --- a/src/admin/Bootstrap.Admin/Views/Admin/Settings.cshtml +++ b/src/admin/Bootstrap.Admin/Views/Admin/Settings.cshtml @@ -202,6 +202,45 @@ +
+
日志缓存设置
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/settings.js b/src/admin/Bootstrap.Admin/wwwroot/js/settings.js index 4c4820e6..065e98dd 100644 --- a/src/admin/Bootstrap.Admin/wwwroot/js/settings.js +++ b/src/admin/Bootstrap.Admin/wwwroot/js/settings.js @@ -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); + } + } + }); } }); diff --git a/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs index fd8a1c32..b92c2ca9 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/DictHelper.cs @@ -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() {