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(), "