From a2d51bd87dadb8e7056cc93ec03a15488fb864f8 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 11 Apr 2023 11:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/system/SystemRouteServices.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/crmeb/app/services/system/SystemRouteServices.php b/crmeb/app/services/system/SystemRouteServices.php index ea641afed..3a3c16e3f 100644 --- a/crmeb/app/services/system/SystemRouteServices.php +++ b/crmeb/app/services/system/SystemRouteServices.php @@ -121,16 +121,30 @@ class SystemRouteServices extends BaseServices $route = $this->app->route->getRuleList(); $action_arr = ['index', 'read', 'create', 'save', 'edit', 'update', 'delete']; - foreach ($route as &$item) { + + foreach ($route as $key => $item) { $real_name = $item['option']['real_name'] ?? ''; if (is_array($real_name)) { - foreach ($action_arr as $action) { - if (Str::contains($item['route'], $action)) { - $real_name = $real_name[$action] ?? ''; + foreach ($action_arr as $a) { + if (Str::contains($item['route'], $a)) { + $real_name = $real_name[$a] ?? ''; } } } $item['option']['real_name'] = $real_name; + $route[$key] = $item; + $except = $item['option']['except'] ?? []; + + $router = is_string($item['route']) ? explode('/', $item['route']) : []; + $action = $router[count($router) - 1] ?? null; + //去除不需要的路由 + if ($except && $action && in_array($action, $except)) { + unset($route[$key]); + } + $only = $item['option']['only'] ?? []; + if ($only && $action && !in_array($action, $only)) { + unset($route[$key]); + } } return $route;