diff --git a/Bootstrap.Admin/Content/js/log.js b/Bootstrap.Admin/Content/js/log.js index a3e7cfa4..b118c429 100644 --- a/Bootstrap.Admin/Content/js/log.js +++ b/Bootstrap.Admin/Content/js/log.js @@ -1,22 +1,9 @@ (function ($) { - LogPlugin = function (options) { - var that = this; - this.options = $.extend({}, LogPlugin.settings, options); - - // handler click event - for (name in this.options.click) { - var cId = this.options.click[name]; - var source = $("#" + cId); - source.data('click', name); - source.click(function () { - var method = $(this).data('click'); - LogPlugin.prototype[method].call(that, this); - }); - } - + logPlugin = function (options) { + this.options = $.extend({}, logPlugin.settings, options); } - LogPlugin.settings = { + logPlugin.settings = { url: '../api/Logs', click: { query: 'btn_query', @@ -25,14 +12,43 @@ } } - LogPlugin.prototype = { - constructor: LogPlugin, + logPlugin.prototype = { + constructor: logPlugin, + init: function () { + var that = this; + // handler click event + for (name in this.options.click) { + var cId = this.options.click[name]; + var source = $("#" + cId); + source.data('click', name); + source.click(function () { + var method = $(this).data('click'); + logPlugin.prototype[method].call(that, this); + }); + } + }, query: function (element) { - log(this.options.url, { crud: 'Query' }); + //log(this.options.url, { crud: '查询' }); + }, + save: function () { + log(this.options.url, { crud: '保存' }); + }, + del: function () { + log(this.options.url, { crud: '删除' }); } } + logPlugin.init = function (options) { + var log = new logPlugin(options); + log.init(); + } + var log = function (url, data) { + $.extend(data, { requestUrl: window.location.pathname }); $.post(url, data); } -})(jQuery); \ No newline at end of file +})(jQuery); + +$(function () { + logPlugin.init(); +}); \ No newline at end of file diff --git a/Bootstrap.Admin/Controllers/LogsController.cs b/Bootstrap.Admin/Controllers/LogsController.cs index 3db5d7ab..76eb8b84 100644 --- a/Bootstrap.Admin/Controllers/LogsController.cs +++ b/Bootstrap.Admin/Controllers/LogsController.cs @@ -34,7 +34,6 @@ namespace Bootstrap.Admin.Controllers { var request = HttpContext.Current.Request; value.ClientAgent = request.UserAgent; - value.RequestUrl = request.Url.AbsolutePath; value.ClientIp = request.UserHostAddress; value.UserName = HttpContext.Current.User.Identity.Name; return LogHelper.SaveLog(value); diff --git a/Bootstrap.Admin/Scripts/Logs.js b/Bootstrap.Admin/Scripts/Logs.js index ac0ba73d..50cb0f2b 100644 --- a/Bootstrap.Admin/Scripts/Logs.js +++ b/Bootstrap.Admin/Scripts/Logs.js @@ -17,5 +17,4 @@ { title: "操作模块", field: "RequestUrl", sortable: false } ] }); - var log = new LogPlugin(); }); \ No newline at end of file diff --git a/Bootstrap.Admin/Views/Shared/_Admin.cshtml b/Bootstrap.Admin/Views/Shared/_Admin.cshtml index 75b18e01..6d7bac14 100644 --- a/Bootstrap.Admin/Views/Shared/_Admin.cshtml +++ b/Bootstrap.Admin/Views/Shared/_Admin.cshtml @@ -16,7 +16,6 @@ - @RenderSection("Javascript", false)