From 5979088144cfb14ea2b8b8377b222044bc2aecd1 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Tue, 22 Sep 2020 11:14:51 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=96=B0=E5=A2=9E=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=BC=93=E5=AD=98=EF=BC=8C=E6=8F=90=E9=AB=98=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/system/controller/Module.php | 24 ++++++++++++++++++++++++ catch/system/route.php | 3 +++ extend/catcher/CatchAdmin.php | 4 ++-- extend/catcher/CatchAdminService.php | 4 +++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/catch/system/controller/Module.php b/catch/system/controller/Module.php index ee1da0b..1b923c4 100644 --- a/catch/system/controller/Module.php +++ b/catch/system/controller/Module.php @@ -53,4 +53,28 @@ class Module extends CatchController return CatchResponse::success(); } + + /** + * 缓存 + * + * @time 2020年09月21日 + * @return Json + */ + public function cache() + { + return CatchResponse::success(CatchAdmin::cacheServices()); + } + + /** + * 清理缓存 + * + * @time 2020年09月21日 + * @return Json + */ + public function clear() + { + return !file_exists(CatchAdmin::getCacheServicesFile()) ? + CatchResponse::fail('模块没有缓存') : + CatchResponse::success(unlink(CatchAdmin::getCacheServicesFile())); + } } \ No newline at end of file diff --git a/catch/system/route.php b/catch/system/route.php index 59ac9aa..883ea18 100644 --- a/catch/system/route.php +++ b/catch/system/route.php @@ -40,6 +40,9 @@ $router->group(function () use ($router) { // 模块管理 $router->get('modules', '\catchAdmin\system\controller\Module@index'); $router->put('modules/', '\catchAdmin\system\controller\Module@disOrEnable'); + $router->put('cache/modules', '\catchAdmin\system\controller\Module@cache'); + $router->delete('clear/modules', '\catchAdmin\system\controller\Module@clear'); + })->middleware('auth'); diff --git a/extend/catcher/CatchAdmin.php b/extend/catcher/CatchAdmin.php index fa61002..4f4066a 100644 --- a/extend/catcher/CatchAdmin.php +++ b/extend/catcher/CatchAdmin.php @@ -377,7 +377,7 @@ class CatchAdmin public static function cacheServices() { return file_put_contents(self::getCacheServicesFile(), "