From 962f89189840e51a660e252edcf9f074d292a113 Mon Sep 17 00:00:00 2001 From: chenlan <18339827479@163.com> Date: Thu, 14 Aug 2025 11:06:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=9D=83=E9=99=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=9D=97=E5=84=BF=E6=B3=A8=E9=87=8A=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PermLogic.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/common/logic/PermLogic.php b/app/common/logic/PermLogic.php index d2e4505..808cb15 100644 --- a/app/common/logic/PermLogic.php +++ b/app/common/logic/PermLogic.php @@ -23,12 +23,16 @@ class PermLogic } $all = collect(); - - // 合并角色资源,排除不需要权限认证的资源 + // 遍历用户的所有角色,合并每个角色所拥有的资源 foreach ($user->roles as $role) { $all = $all->merge( + // 过滤当前角色的资源列表 $role->resources->filter(function ($resource) use($system) { - // 只保留需要权限认证的资源(或公共资源) + // 资源过滤条件: + // 1. !$resource->no_auth:资源需要权限认证(排除公共资源) + // 2. 系统匹配条件: + // - $system->id == $resource->system_id:资源属于当前系统 + // - $resource->system_id == 0:资源为全局公共资源(所有系统可用) return !$resource->no_auth && ($system->id == $resource->system_id || $resource->system_id == 0); }) );