重构代码:根据最新的Longbow.Cache组件更新CacheList.axd?clear=clear,移动跨域缓存中间件移动到角色授权中间件后
This commit is contained in:
parent
0d3218dca8
commit
8883e48b61
|
@ -62,11 +62,11 @@ namespace Bootstrap.Admin
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Home/Error");
|
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.UseStaticFiles();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseCacheManagerCorsHandler();
|
|
||||||
app.UseBootstrapRoleAuthorization();
|
app.UseBootstrapRoleAuthorization();
|
||||||
|
app.UseCacheManagerCorsHandler();
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
{
|
{
|
||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">网站缓存<a id="refreshCache" href="#" class="pull-right fa fa-refresh" title="点击刷新" data-placement="left" role="tooltip"></a></div>
|
<div class="panel-heading">网站缓存<a data-method="clear" href="#" class="clearcache fa fa-times-circle-o" data-admin="@User.IsInRole("Administrators")" title="全部清除" role="tooltip" data-placement="left"></a><a data-method="refresh" href="#" class="pull-right fa fa-refresh" title="点击刷新" role="tooltip"></a></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="tasks-widget">
|
<div class="tasks-widget">
|
||||||
<ul id="sortable" class="task-list ui-sortable"></ul>
|
<ul id="sortable" class="task-list ui-sortable"></ul>
|
||||||
|
|
|
@ -18,5 +18,6 @@
|
||||||
"DbProviderFactories": {
|
"DbProviderFactories": {
|
||||||
"sql": "SQLServer"
|
"sql": "SQLServer"
|
||||||
},
|
},
|
||||||
"KeyPath": "C:\\keys"
|
"KeyPath": "C:\\keys",
|
||||||
|
"AllowOrigins": "http://localhost:49823"
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
{
|
{
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"Name": "ba",
|
"Name": "ba",
|
||||||
"Url": "http://localhost:50852/CacheList.axd?cacheKey={0}",
|
"Url": "http://localhost:50852/CacheList.axd",
|
||||||
"Desc": "后台管理数据缓存接口",
|
"Desc": "后台管理数据缓存接口",
|
||||||
"Self": true
|
"Self": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"Name": "ba",
|
"Name": "Pallet",
|
||||||
"Url": "http://localhost:49823/CacheList.axd?cacheKey={0}",
|
"Url": "http://localhost:49823/CacheList.axd",
|
||||||
"Desc": "托盘组垛系统数据缓存接口",
|
"Desc": "托盘组垛系统",
|
||||||
"Self": false
|
"Self": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -129,8 +129,7 @@
|
||||||
callback: null,
|
callback: null,
|
||||||
$element: null,
|
$element: null,
|
||||||
async: true,
|
async: true,
|
||||||
toastr: false,
|
toastr: false
|
||||||
crossDomain: null
|
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
if (!options.url || options.url === "") {
|
if (!options.url || options.url === "") {
|
||||||
|
@ -156,7 +155,6 @@
|
||||||
contentType: options.contentType,
|
contentType: options.contentType,
|
||||||
dataType: options.dataType,
|
dataType: options.dataType,
|
||||||
async: options.async,
|
async: options.async,
|
||||||
crossDomain: options.crossDomain,
|
|
||||||
xhrFields: options.xhrFields,
|
xhrFields: options.xhrFields,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
success(result);
|
success(result);
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
var $sortable = $('#sortable');
|
var $sortable = $('#sortable');
|
||||||
var listCacheUrl = function (options) {
|
var listCacheUrl = function (options) {
|
||||||
options = $.extend({ key: '' }, options);
|
options = $.extend({ clear: false }, options);
|
||||||
$sortable.html('');
|
$sortable.html('');
|
||||||
$.bc({
|
$.bc({
|
||||||
url: Settings.url,
|
url: Settings.url,
|
||||||
|
@ -60,16 +60,17 @@
|
||||||
callback: function (result) {
|
callback: function (result) {
|
||||||
if (result && $.isArray(result)) {
|
if (result && $.isArray(result)) {
|
||||||
$.each(result, function (index, item) {
|
$.each(result, function (index, item) {
|
||||||
|
if (options.clear) options.url = item.Url + "?clear=clear";
|
||||||
|
else options.url = item.Url;
|
||||||
$.bc({
|
$.bc({
|
||||||
url: $.format(item.Url, options.key),
|
url: options.url,
|
||||||
crossDomain: !item.Self,
|
|
||||||
xhrFields: {
|
xhrFields: {
|
||||||
withCredentials: !item.Self
|
withCredentials: true
|
||||||
},
|
},
|
||||||
swal: false,
|
swal: false,
|
||||||
callback: function (result) {
|
callback: function (result) {
|
||||||
if ($.isArray(result)) {
|
if ($.isArray(result)) {
|
||||||
var html = '<li class="{4}"><i class="fa fa-ellipsis-v"></i><div class="task-title"><span class="task-title-sp" role="tooltip" title="{1}">{2}</span><span class="badge badge-sm label-success">{0}</span><span class="task-value" title="{3}">{3}</span><div class="pull-right hidden-phone"><span>{7}</span><button class="btn btn-danger btn-xs fa fa-trash-o" title="{1}" data-url="{5}" role="tooltip" data-self="{6}" data-placement="left"></button></div></div></li>';
|
var html = '<li class="{4}"><i class="fa fa-ellipsis-v"></i><div class="task-title"><span class="task-title-sp" role="tooltip" title="{1}">{2}</span><span class="badge badge-sm label-success">{0}</span><span class="task-value" title="{3}">{3}</span><div class="pull-right hidden-phone"><span>{7}</span><button class="btn btn-danger btn-xs fa fa-trash-o" title="{1}" data-url="{5}?cacheKey={1}" role="tooltip" data-self="{6}" data-placement="left"></button></div></div></li>';
|
||||||
var content = result.sort(function (x, y) {
|
var content = result.sort(function (x, y) {
|
||||||
return x.Key > y.Key ? 1 : -1;
|
return x.Key > y.Key ? 1 : -1;
|
||||||
}).map(function (ele) {
|
}).map(function (ele) {
|
||||||
|
@ -126,17 +127,29 @@
|
||||||
var listCache = function (options) {
|
var listCache = function (options) {
|
||||||
$.bc({
|
$.bc({
|
||||||
url: options.url,
|
url: options.url,
|
||||||
crossDomain: !options.self,
|
|
||||||
xhrFields: {
|
xhrFields: {
|
||||||
withCredentials: !options.self
|
withCredentials: true
|
||||||
},
|
},
|
||||||
swal: false
|
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 () {
|
$sortable.on('click', '.btn', function () {
|
||||||
$(this).lgbTooltip('destroy');
|
$(this).lgbTooltip('destroy');
|
||||||
listCache({ self: $(this).attr('data-self') === "true", url: $(this).attr('data-url') });
|
listCache({ url: $(this).attr('data-url') });
|
||||||
listCacheUrl();
|
listCacheUrl();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue