From f07cbadc0574a2a9e1adb4d48ac800edb841602f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 18 Mar 2025 10:29:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor(admin):=20=E4=BC=98=E5=8C=96=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E6=9D=83=E9=99=90=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 AdminLogic 中 getMenuByAdminId 方法的调用,增加 false 参数以获取完整菜单 - 优化 MenuLogic 中的查询条件判断逻辑,提高代码可读性 --- app/admin/logic/auth/AdminLogic.php | 2 +- app/admin/logic/auth/MenuLogic.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/admin/logic/auth/AdminLogic.php b/app/admin/logic/auth/AdminLogic.php index a1a909f..af12872 100644 --- a/app/admin/logic/auth/AdminLogic.php +++ b/app/admin/logic/auth/AdminLogic.php @@ -232,7 +232,7 @@ class AdminLogic extends BaseLogic $result['user'] = $admin; // 当前管理员角色拥有的菜单 - $result['menu'] = MenuLogic::getMenuByAdminId($params['id']); + $result['menu'] = MenuLogic::getMenuByAdminId($params['id'],false); $result['top_menu'] = MenuLogic::getMenuByAdminId($params['id'],true); // 当前管理员橘色拥有的按钮权限 diff --git a/app/admin/logic/auth/MenuLogic.php b/app/admin/logic/auth/MenuLogic.php index 31d72f3..911a5af 100644 --- a/app/admin/logic/auth/MenuLogic.php +++ b/app/admin/logic/auth/MenuLogic.php @@ -50,11 +50,9 @@ class MenuLogic extends BaseLogic $where[] = ['type', 'in', ['M', 'C']]; $where[] = ['is_disable', '=', 0]; - if($is_top==true){ + if ($is_top==true) { $menu_where[]=['is_top','=',1]; $where[] = ['pid', '=', 0]; - } - if ($admin['root'] != 1 || $is_top==true) { if(!empty($admin['role_id'])){ $menu_where[]=['role_id','in',$admin['role_id']]; }