From f6c05660607e9d76a984bcf55b41e192c0a7b6e3 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Thu, 10 Feb 2022 10:54:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8E=E5=8F=B0=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E9=80=89=E4=B8=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Admin/Layout/Menu.php | 24 ++++++++++-------------- app/Providers/AppServiceProvider.php | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/Models/Admin/Layout/Menu.php b/app/Models/Admin/Layout/Menu.php index de9d655c..2b0b5cc0 100644 --- a/app/Models/Admin/Layout/Menu.php +++ b/app/Models/Admin/Layout/Menu.php @@ -22,27 +22,23 @@ class Menu extends DcatLayoutMenu if (empty($item['uri'])) { return false; } - // return trim($this->getPath($item['uri']), '/') == $path; - // dd($path, trim($this->getPath($item['uri']), '/admin'), strpos($path, trim($this->getPath($item['uri']), '/admin'))); - $_uri = trim($this->getPath($item['uri']), '/admin'); - if (empty($_uri) && $path!=='admin') { + $_uri = trim(str_replace('/admin', '', $this->getPath($item['uri'])), '/'); + if (empty($_uri) && $path !== 'admin') { return false; } return strpos($path, $_uri) !== false; } - foreach ($item['children'] as $v) { - // $_uri = trim($this->getPath($item['uri']), '/admin'); - // if (empty($_uri) && $path!=='admin') { - // return false; - // } - // if (strpos($path, $_uri) !== false) { - // return true; - // } - dd($v, empty($v['children'])); + $_uri = trim(str_replace('/admin', '', $this->getPath($v['uri'])), '/'); + if (empty($_uri) && $path !== 'admin') { + return false; + } + if (strpos($path, $_uri) !== false) { + return true; + } + //针对大于2级的菜单 if (! empty($v['children'])) { - dd($v, $path); if ($this->isActive($v, $path)) { return true; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index f6559aa8..74e95c0d 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -27,7 +27,7 @@ class AppServiceProvider extends ServiceProvider $this->registerEasyWeChat(); $this->registerRequestRealIp(); $this->registerSettings(); - // $this->registerAdminMenu(); + $this->registerAdminMenu(); } /**