From aea9eb6a17e64c3bc4e10dd2f2c6de4a42f36696 Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Sun, 15 Dec 2019 15:51:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E7=94=B1=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchAdmin.php | 38 ++++++++++++++--------- extend/catcher/event/LoadModuleRoutes.php | 16 +++++----- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/extend/catcher/CatchAdmin.php b/extend/catcher/CatchAdmin.php index 878a492..583f043 100644 --- a/extend/catcher/CatchAdmin.php +++ b/extend/catcher/CatchAdmin.php @@ -244,17 +244,15 @@ class CatchAdmin /** * * @time 2019年11月30日 - * @return string + * @return mixed */ - public static function getRoutes(): string + public static function getRoutes() { if (file_exists(self::getCacheRoutesFile())) { return self::getCacheRoutesFile(); } - self::cacheRoutes(); - - return self::getCacheRoutesFile(); + return self::getModuleRoutes(); } /** @@ -271,6 +269,24 @@ class CatchAdmin return self::getModuleViews(); } + /** + * + * @time 2019年12月15日 + * @return array + */ + public static function getModuleRoutes(): array + { + $routeFiles = []; + foreach (self::getModulesDirectory() as $module) { + $moduleInfo = self::getModuleInfo($module); + if (!in_array($moduleInfo['alias'], ['login']) && file_exists($module . 'route.php')) { + $routeFiles[] = $module . 'route.php'; + } + } + + return $routeFiles; + + } /** * * @time 2019年11月30日 @@ -278,17 +294,9 @@ class CatchAdmin */ public static function cacheRoutes() { - $routeFiles = []; - foreach (self::getModulesDirectory() as $module) { - $moduleInfo = self::getModuleInfo($module); - if (!in_array($moduleInfo['alias'], ['login'])) { - if (file_exists($module . 'route.php')) { - $routeFiles[] = $module . 'route.php'; - } - } - } $routes = ''; - foreach ($routeFiles as $route) { + + foreach (self::getModuleRoutes() as $route) { $routes .= trim(str_replace('