From 8883e48b61c8c565c4a31490ef07d9ad63740510 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Sat, 9 Jun 2018 17:04:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81=EF=BC=9A?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=9C=80=E6=96=B0=E7=9A=84Longbow.Cache?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=9B=B4=E6=96=B0CacheList.axd=3Fclear=3Dcle?= =?UTF-8?q?ar=EF=BC=8C=E7=A7=BB=E5=8A=A8=E8=B7=A8=E5=9F=9F=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E4=B8=AD=E9=97=B4=E4=BB=B6=E7=A7=BB=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=8E=88=E6=9D=83=E4=B8=AD=E9=97=B4=E4=BB=B6?= =?UTF-8?q?=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Startup.cs | 4 +-- Bootstrap.Admin/Views/Admin/Settings.cshtml | 2 +- Bootstrap.Admin/appsettings.json | 3 +- Bootstrap.Admin/cache.json | 8 ++--- Bootstrap.Admin/wwwroot/js/Longbow.Common.js | 4 +-- Bootstrap.Admin/wwwroot/js/Settings.js | 31 ++++++++++++++------ 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Bootstrap.Admin/Startup.cs b/Bootstrap.Admin/Startup.cs index 4af940c9..45f2ce96 100644 --- a/Bootstrap.Admin/Startup.cs +++ b/Bootstrap.Admin/Startup.cs @@ -62,11 +62,11 @@ namespace Bootstrap.Admin { app.UseExceptionHandler("/Home/Error"); } - app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials()); + app.UseCors(builder => builder.WithOrigins(Configuration["AllowOrigins"].Split(',', StringSplitOptions.RemoveEmptyEntries)).AllowAnyHeader().AllowAnyMethod().AllowCredentials()); app.UseStaticFiles(); app.UseAuthentication(); - app.UseCacheManagerCorsHandler(); app.UseBootstrapRoleAuthorization(); + app.UseCacheManagerCorsHandler(); app.UseMvc(routes => { routes.MapRoute( diff --git a/Bootstrap.Admin/Views/Admin/Settings.cshtml b/Bootstrap.Admin/Views/Admin/Settings.cshtml index 165cfb3b..dda856f7 100644 --- a/Bootstrap.Admin/Views/Admin/Settings.cshtml +++ b/Bootstrap.Admin/Views/Admin/Settings.cshtml @@ -58,7 +58,7 @@
-
网站缓存
+
网站缓存
    diff --git a/Bootstrap.Admin/appsettings.json b/Bootstrap.Admin/appsettings.json index fe4d1fa7..1344b75f 100644 --- a/Bootstrap.Admin/appsettings.json +++ b/Bootstrap.Admin/appsettings.json @@ -18,5 +18,6 @@ "DbProviderFactories": { "sql": "SQLServer" }, - "KeyPath": "C:\\keys" + "KeyPath": "C:\\keys", + "AllowOrigins": "http://localhost:49823" } diff --git a/Bootstrap.Admin/cache.json b/Bootstrap.Admin/cache.json index dad57eb0..7182c0be 100644 --- a/Bootstrap.Admin/cache.json +++ b/Bootstrap.Admin/cache.json @@ -5,15 +5,15 @@ { "Enabled": true, "Name": "ba", - "Url": "http://localhost:50852/CacheList.axd?cacheKey={0}", + "Url": "http://localhost:50852/CacheList.axd", "Desc": "后台管理数据缓存接口", "Self": true }, { "Enabled": true, - "Name": "ba", - "Url": "http://localhost:49823/CacheList.axd?cacheKey={0}", - "Desc": "托盘组垛系统数据缓存接口", + "Name": "Pallet", + "Url": "http://localhost:49823/CacheList.axd", + "Desc": "托盘组垛系统", "Self": false } ], diff --git a/Bootstrap.Admin/wwwroot/js/Longbow.Common.js b/Bootstrap.Admin/wwwroot/js/Longbow.Common.js index bab95aea..4501ef12 100644 --- a/Bootstrap.Admin/wwwroot/js/Longbow.Common.js +++ b/Bootstrap.Admin/wwwroot/js/Longbow.Common.js @@ -129,8 +129,7 @@ callback: null, $element: null, async: true, - toastr: false, - crossDomain: null + toastr: false }, options); if (!options.url || options.url === "") { @@ -156,7 +155,6 @@ contentType: options.contentType, dataType: options.dataType, async: options.async, - crossDomain: options.crossDomain, xhrFields: options.xhrFields, success: function (result) { success(result); diff --git a/Bootstrap.Admin/wwwroot/js/Settings.js b/Bootstrap.Admin/wwwroot/js/Settings.js index 6b624853..90cecfc9 100644 --- a/Bootstrap.Admin/wwwroot/js/Settings.js +++ b/Bootstrap.Admin/wwwroot/js/Settings.js @@ -51,7 +51,7 @@ var $sortable = $('#sortable'); var listCacheUrl = function (options) { - options = $.extend({ key: '' }, options); + options = $.extend({ clear: false }, options); $sortable.html(''); $.bc({ url: Settings.url, @@ -60,16 +60,17 @@ callback: function (result) { if (result && $.isArray(result)) { $.each(result, function (index, item) { + if (options.clear) options.url = item.Url + "?clear=clear"; + else options.url = item.Url; $.bc({ - url: $.format(item.Url, options.key), - crossDomain: !item.Self, + url: options.url, xhrFields: { - withCredentials: !item.Self + withCredentials: true }, swal: false, callback: function (result) { if ($.isArray(result)) { - var html = '
  • {2}{0}{3}
    {7}
  • '; + var html = '
  • {2}{0}{3}
    {7}
  • '; var content = result.sort(function (x, y) { return x.Key > y.Key ? 1 : -1; }).map(function (ele) { @@ -126,17 +127,29 @@ var listCache = function (options) { $.bc({ url: options.url, - crossDomain: !options.self, xhrFields: { - withCredentials: !options.self + withCredentials: true }, swal: false }); } - $('#refreshCache').click(function () { listCacheUrl(); }).trigger('click'); + $('a[data-method]').on('click', function (e) { + e.preventDefault(); + e.stopPropagation(); + var $this = $(this); + var options = {}; + switch ($this.attr('data-method')) { + case 'clear': + options.clear = true; + break; + case 'refresh': + break; + } + listCacheUrl(options); + }).last().trigger('click'); $sortable.on('click', '.btn', function () { $(this).lgbTooltip('destroy'); - listCache({ self: $(this).attr('data-self') === "true", url: $(this).attr('data-url') }); + listCache({ url: $(this).attr('data-url') }); listCacheUrl(); });