From 0b365562cbe9314b862a4f06c9e1301ed023d6c6 Mon Sep 17 00:00:00 2001 From: PPPSCN <35696959@qq.com> Date: Fri, 5 May 2017 15:42:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B8=85=E9=99=A4=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Ajax.php | 22 ++++++++++++++++++++++ application/admin/view/common/header.html | 6 ++++++ public/assets/js/backend/index.js | 16 ++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index 68f20705..b9ebaf54 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -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('清空系统缓存成功!'); + } + } diff --git a/application/admin/view/common/header.html b/application/admin/view/common/header.html index 839fdcc3..8e99d6ae 100644 --- a/application/admin/view/common/header.html +++ b/application/admin/view/common/header.html @@ -42,6 +42,12 @@ +
  • + + + +
  • +