mirror of https://gitee.com/karson/fastadmin.git
增加清除缓存的功能
parent
e10619221f
commit
0b365562cb
|
|
@ -9,6 +9,7 @@ use fast\Tree;
|
|||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Lang;
|
||||
use think\Cache;
|
||||
|
||||
/**
|
||||
* Ajax异步请求接口
|
||||
|
|
@ -339,4 +340,25 @@ class Ajax extends Backend
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空系统缓存
|
||||
*/
|
||||
public function wipeCache()
|
||||
{
|
||||
$wipe_cache_type = ['TEMP_PATH', 'LOG_PATH', 'CACHE_PATH'];
|
||||
foreach ($wipe_cache_type as $item) {
|
||||
if ($item == 'LOG_PATH') {
|
||||
$dirs = (array) glob(constant($item) . '*');
|
||||
foreach ($dirs as $dir) {
|
||||
array_map('unlink', (array) glob($dir . DIRECTORY_SEPARATOR . '*.*'));
|
||||
}
|
||||
array_map('rmdir', $dirs);
|
||||
} else {
|
||||
array_map('unlink', (array) glob(constant($item) . DIRECTORY_SEPARATOR . '*.*'));
|
||||
}
|
||||
}
|
||||
Cache::clear();
|
||||
$this->success('清空系统缓存成功!');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@
|
|||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="javascript:;" data-toggle="wipeCache" title="清空缓存">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-language"></i></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
|
|
|||
|
|
@ -47,6 +47,22 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'validator'], f
|
|||
e.stopPropagation();
|
||||
});
|
||||
|
||||
//清除缓存
|
||||
$(document).on('click', "[data-toggle='wipeCache']", function () {
|
||||
$.ajax({
|
||||
url: 'ajax/wipeCache',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function (ret) {
|
||||
if (ret.code === 1) {
|
||||
Backend.api.toastr.success(ret.msg);
|
||||
} else {
|
||||
Backend.api.toastr.error('清除系统缓存失败!');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//全屏事件
|
||||
$(document).on('click', "[data-toggle='fullscreen']", function () {
|
||||
var doc = document.documentElement;
|
||||
|
|
|
|||
Loading…
Reference in New Issue