diff --git a/Bootstrap.Admin/Views/Admin/Logs.cshtml b/Bootstrap.Admin/Views/Admin/Logs.cshtml index 78c64fb6..112e6188 100644 --- a/Bootstrap.Admin/Views/Admin/Logs.cshtml +++ b/Bootstrap.Admin/Views/Admin/Logs.cshtml @@ -77,4 +77,31 @@
- \ No newline at end of file + +@section modal { + +} \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/css/site.css b/Bootstrap.Admin/wwwroot/css/site.css index d2be26a9..3acbefc2 100644 --- a/Bootstrap.Admin/wwwroot/css/site.css +++ b/Bootstrap.Admin/wwwroot/css/site.css @@ -569,3 +569,31 @@ li[data-category="1"] .dd3-content .menuType { .bootstrap-table .badge { padding: 4px 6px; } + +pre { + padding: 5px; + margin: 5px; + width: 100%; + border-radius: 4px; + border: solid 1px #ccc; +} + +.string { + color: green; +} + +.number { + color: darkorange; +} + +.boolean { + color: blue; +} + +.null { + color: magenta; +} + +.key { + color: red; +} diff --git a/Bootstrap.Admin/wwwroot/js/log.js b/Bootstrap.Admin/wwwroot/js/log.js index 7f7f477a..a83eb8e8 100644 --- a/Bootstrap.Admin/wwwroot/js/log.js +++ b/Bootstrap.Admin/wwwroot/js/log.js @@ -33,6 +33,33 @@ }, '#btnReset': function () { this.log({ crud: '重置密码' }); + }, + '#btnSaveDisplayName': function () { + this.log({ crud: '设置显示名称' }); + }, + '#btnSavePassword': function () { + this.log({ crud: '修改密码' }); + }, + '#btnSaveApp': function () { + this.log({ crud: '设置默认应用' }); + }, + '#btnSaveCss': function () { + this.log({ crud: '设置个人样式' }); + }, + 'a.btn.fileinput-upload-button': function () { + this.log({ crud: '设置头像' }); + }, + 'button.kv-file-remove': function () { + this.log({ crud: '删除头像' }); + }, + 'button[data-method="title"]': function () { + this.log({ crud: '保存网站标题'}); + }, + 'button[data-method="footer"]': function () { + this.log({ crud: '保存网站页脚' }); + }, + 'button[data-method="css"]': function () { + this.log({ crud: '设置网站样式' }); } } }; @@ -40,6 +67,8 @@ logPlugin.prototype = { constructor: logPlugin, log: function (data) { + var bcData = $.logData.shift(); + if (bcData !== undefined) $.extend(data, { requestData: JSON.stringify(bcData) }); $.extend(data, { requestUrl: window.location.pathname }); $.post({ url: $.formatUrl(this.options.url), @@ -51,6 +80,7 @@ }; $.extend({ logPlugin: function (options) { return new logPlugin(options); } }); + $.logData = []; })(jQuery); $(function () { diff --git a/Bootstrap.Admin/wwwroot/js/logs.js b/Bootstrap.Admin/wwwroot/js/logs.js index 5b3244dd..fba2881f 100644 --- a/Bootstrap.Admin/wwwroot/js/logs.js +++ b/Bootstrap.Admin/wwwroot/js/logs.js @@ -1,5 +1,7 @@ $(function () { var url = 'api/Logs'; + var $data = $('#requestData'); + var $dialog = $('#dialogRequestData'); $('.card-body table').smartTable({ url: url, @@ -14,10 +16,22 @@ { title: "操作地点", field: "City", sortable: true }, { title: "浏览器", field: "Browser", sortable: true }, { title: "操作系统", field: "OS", sortable: true }, - { title: "Url", field: "RequestUrl", sortable: true } + { title: "操作页面", field: "RequestUrl", sortable: true }, + { + title: "请求数据", field: "RequestData", sortable: true, formatter: function (value, row, index) { + return ''; + }, + events: { + 'click .detail': function (e, value, row, index) { + $data.html($.syntaxHighlight(row.RequestData)); + $dialog.modal('show'); + } + } + } ], exportOptions: { - fileName: "操作日志数据" + fileName: "操作日志数据", + ignoreColumn: [8] } }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js b/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js index 3dedec22..bea77dc2 100644 --- a/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js +++ b/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js @@ -208,6 +208,7 @@ xhrFields: { withCredentials: true }, crossDomain: true }); + if ($.isArray($.logData) && !$.isEmptyObject(options.data)) $.logData.push({ url: url, data: options.data }); $.ajax(ajaxSettings); }, lgbSwal: function (options) { @@ -231,6 +232,30 @@ if (url.substr(0, 4) === "http") return url; var base = $('#pathBase').attr('href'); return base + url; + }, + syntaxHighlight: function (json) { + if (typeof (json) === 'string') { + json = JSON.parse(json); + } + json = JSON.stringify(json, undefined, 2); + json = json.replace(/&/g, '&').replace(//g, '>'); + return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, + function (match) { + var cls = 'number'; + if (/^"/.test(match)) { + if (/:$/.test(match)) { + cls = 'key'; + } else { + cls = 'string'; + } + } else if (/true|false/.test(match)) { + cls = 'boolean'; + } else if (/null/.test(match)) { + cls = 'null'; + } + return '' + match + ''; + } + ); } }); diff --git a/Bootstrap.DataAccess/Log.cs b/Bootstrap.DataAccess/Log.cs index ca736f1e..3a71d51f 100644 --- a/Bootstrap.DataAccess/Log.cs +++ b/Bootstrap.DataAccess/Log.cs @@ -53,6 +53,11 @@ namespace Bootstrap.DataAccess /// public string RequestUrl { get; set; } + /// + /// 获得/设置 请求数据 + /// + public string RequestData { get; set; } + /// /// 查询所有日志信息 ///