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(); });