From 58aadbc1f5f7d369ccbd16b6b934e113391c0c16 Mon Sep 17 00:00:00 2001 From: mzl Date: Tue, 22 Jul 2025 10:41:38 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PermLogic.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/app/common/logic/PermLogic.php b/app/common/logic/PermLogic.php index 275912b..b1ea2f3 100644 --- a/app/common/logic/PermLogic.php +++ b/app/common/logic/PermLogic.php @@ -52,7 +52,6 @@ class PermLogic return $all->unique('id')->values()->sortBy('sort'); } - /** * 构建目录/菜单树,节点包含权限与打开方式,拼接完整路径,并对子级菜单 component 处理 * @@ -66,13 +65,13 @@ class PermLogic $tree = []; foreach ($resources as $node) { - if ($node->parent_id !== $parentId) { + // 只处理目录和菜单,不把 permission 当作菜单节点 + if ($node->parent_id !== $parentId || $node->type === 'permission') { continue; } // —— 拼接当前节点的完整路径 —— $currentPath = rtrim($parentPath, '/'); - if (!empty($node->url)) { $urlSegment = ltrim($node->url, '/'); $currentPath = $currentPath === '' @@ -81,10 +80,8 @@ class PermLogic } // —— 递归构建子节点 —— - $children = []; - if (in_array($node->type, ['directory', 'menu'])) { - $children = $this->buildTree($resources, $node->id, $currentPath); - } + // 这里只会继续收目录和菜单,permission 永远不会进入此方法 + $children = $this->buildTree($resources, $node->id, $currentPath); // —— 本级权限列表 —— $authList = $resources @@ -98,10 +95,7 @@ class PermLogic ->all(); // —— 判断是否有子目录或子菜单 —— - $hasChildrenMenu = $resources - ->where('parent_id', $node->id) - ->whereIn('type', ['directory', 'menu']) - ->isNotEmpty(); + $hasChildrenMenu = ! empty($children); // —— 计算 component 字段 —— if ($hasChildrenMenu) { From 5e75822e5626c811879759360d1cc01342dcc34f Mon Sep 17 00:00:00 2001 From: mzl Date: Tue, 22 Jul 2025 10:48:09 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PermLogic.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/common/logic/PermLogic.php b/app/common/logic/PermLogic.php index b1ea2f3..a915ea1 100644 --- a/app/common/logic/PermLogic.php +++ b/app/common/logic/PermLogic.php @@ -126,6 +126,8 @@ class PermLogic 'openType' => $node->open_type, ], 'children' => $children, + 'is_hide' => $node->is_hide, + 'is_hide_tab' => $node->is_hide_tab ]; } From d532b85b910d00b9bdf77ad866b4044f830b8e37 Mon Sep 17 00:00:00 2001 From: mzl Date: Tue, 22 Jul 2025 10:57:37 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PermLogic.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/logic/PermLogic.php b/app/common/logic/PermLogic.php index a915ea1..1fb4058 100644 --- a/app/common/logic/PermLogic.php +++ b/app/common/logic/PermLogic.php @@ -124,10 +124,10 @@ class PermLogic 'keepAlive' => true, 'authList' => $authList, 'openType' => $node->open_type, + 'is_hide' => $node->is_hide == 0 ? false : true, + 'is_hide_tab' => $node->is_hide_tab == 0 ? false : true ], - 'children' => $children, - 'is_hide' => $node->is_hide, - 'is_hide_tab' => $node->is_hide_tab + 'children' => $children ]; } From abafe841f82172c3f1e8b7b8c157ffbc9b9c9b08 Mon Sep 17 00:00:00 2001 From: mzl Date: Tue, 22 Jul 2025 11:00:32 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PermLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/common/logic/PermLogic.php b/app/common/logic/PermLogic.php index 1fb4058..515bec9 100644 --- a/app/common/logic/PermLogic.php +++ b/app/common/logic/PermLogic.php @@ -124,8 +124,8 @@ class PermLogic 'keepAlive' => true, 'authList' => $authList, 'openType' => $node->open_type, - 'is_hide' => $node->is_hide == 0 ? false : true, - 'is_hide_tab' => $node->is_hide_tab == 0 ? false : true + 'isHide' => $node->is_hide == 0 ? false : true, + 'isHideTab' => $node->is_hide_tab == 0 ? false : true ], 'children' => $children ]; From 4eca8c46c5e07ec2d1d928779f06536b7a0a0836 Mon Sep 17 00:00:00 2001 From: mzl Date: Tue, 22 Jul 2025 11:34:47 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/utils/scaffold/Generate.php | 36 ++++++++++++++++---------- app/controller/IndexController.php | 22 ++++++++-------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/common/utils/scaffold/Generate.php b/app/common/utils/scaffold/Generate.php index 7cf52ac..6735997 100644 --- a/app/common/utils/scaffold/Generate.php +++ b/app/common/utils/scaffold/Generate.php @@ -26,11 +26,11 @@ class Generate // 模板路径 $templateDir = __DIR__ . '/templates/'; - $controllerPath = __DIR__ . "/../../../{$this->options['controller']['module']}/controller/".ucfirst($this->options['controller']['name'])."Controller.php"; - $servicePath = __DIR__ . "/../../../{$this->options['service']['module']}/service/".ucfirst($this->options['service']['name'])."Service.php"; - $logicPath = __DIR__ . "/../../../{$this->options['logic']['module']}/logic/".ucfirst($this->options['logic']['name'])."Logic.php"; - $modelPath = __DIR__ . "/../../../{$this->options['model']['module']}/model/".ucfirst($this->options['model']['name']).".php"; - $validatePath = __DIR__ . "/../../../{$this->options['validate']['module']}/validate/".ucfirst($this->options['validate']['name'])."Validate.php"; + $controllerPath = __DIR__ . "/../../../{$this->options['controller']['module']}/controller/".$this->rName($this->options['controller']['name'])."Controller.php"; + $servicePath = __DIR__ . "/../../../{$this->options['service']['module']}/service/".$this->rName($this->options['service']['name'])."Service.php"; + $logicPath = __DIR__ . "/../../../{$this->options['logic']['module']}/logic/".$this->rName($this->options['logic']['name'])."Logic.php"; + $modelPath = __DIR__ . "/../../../{$this->options['model']['module']}/model/".$this->rName($this->options['model']['name']).".php"; + $validatePath = __DIR__ . "/../../../{$this->options['validate']['module']}/validate/".$this->rName($this->options['validate']['name'])."Validate.php"; // 创建目录(如果不存在) $fs->mkdir(__DIR__ . "/../../../{$this->options['controller']['module']}/controller"); @@ -86,32 +86,32 @@ class Generate case 'controller': $content = str_replace('{{controllerModule}}', $this->options['controller']['module'], $content); $content = str_replace('{{serviceModule}}', $this->options['service']['module'], $content); - $content = str_replace('{{serviceName}}', ucfirst($this->options['service']['name']), $content); - $content = str_replace('{{controllerName}}', ucfirst($this->options['controller']['name']), $content); + $content = str_replace('{{serviceName}}', $this->rName($this->options['service']['name']), $content); + $content = str_replace('{{controllerName}}', $this->rName($this->options['controller']['name']), $content); break; case 'service': $content = str_replace('{{serviceModule}}', $this->options['service']['module'], $content); $content = str_replace('{{validateModule}}', $this->options['validate']['module'], $content); - $content = str_replace('{{validateName}}', ucfirst($this->options['validate']['name']), $content); + $content = str_replace('{{validateName}}', $this->rName($this->options['validate']['name']), $content); $content = str_replace('{{modelModule}}', $this->options['model']['module'], $content); - $content = str_replace('{{modelName}}', ucfirst($this->options['model']['name']), $content); - $content = str_replace('{{serviceName}}', ucfirst($this->options['service']['name']), $content); + $content = str_replace('{{modelName}}', $this->rName($this->options['model']['name']), $content); + $content = str_replace('{{serviceName}}', $this->rName($this->options['service']['name']), $content); break; case 'logic': $content = str_replace('{{logicModule}}', $this->options['logic']['module'], $content); $content = str_replace('{{modelModule}}', $this->options['model']['module'], $content); - $content = str_replace('{{modelName}}', ucfirst($this->options['model']['name']), $content); - $content = str_replace('{{logicName}}', ucfirst($this->options['logic']['name']), $content); + $content = str_replace('{{modelName}}', $this->rName($this->options['model']['name']), $content); + $content = str_replace('{{logicName}}', $this->rName($this->options['logic']['name']), $content); break; case 'model': $content = str_replace('{{modelModule}}', $this->options['model']['module'], $content); - $content = str_replace('{{modelName}}', ucfirst($this->options['model']['name']), $content); + $content = str_replace('{{modelName}}', $this->rName($this->options['model']['name']), $content); $content = str_replace('{{table}}', $this->options['table'], $content); $content = str_replace('{{fillable}}', $this->fillableFields(), $content); break; case 'validate': $content = str_replace('{{validateModule}}', $this->options['validate']['module'], $content); - $content = str_replace('{{validateName}}', ucfirst($this->options['validate']['name']), $content); + $content = str_replace('{{validateName}}', $this->rName($this->options['validate']['name']), $content); break; } @@ -153,6 +153,14 @@ class Generate echo "删除已存在文件: {$path} \n"; } } + + /** + * 设置名称 + */ + public function rName($name = '') + { + return ucfirst(camelize($name)); + } } /** diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index 125ff1f..6ca6eae 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -71,26 +71,26 @@ class IndexController { $options = [ 'controller' => [ - 'module' => 'admin', - 'name' => 'systems' + 'module' => 'inquiry', + 'name' => 'inquiry_log' ], 'model' => [ - 'module' => 'common', - 'name' => 'systems' + 'module' => 'inquiry', + 'name' => 'inquiry_log' ], 'service' => [ - 'module' => 'admin', - 'name' => 'systems' + 'module' => 'inquiry', + 'name' => 'inquiry_log' ], 'logic' => [ - 'module' => 'common', - 'name' => 'systems' + 'module' => 'inquiry', + 'name' => 'inquiry_log' ], 'validate' => [ - 'module' => 'common', - 'name' => 'systems' + 'module' => 'inquiry', + 'name' => 'inquiry_log' ], - 'table' => 'systems' + 'table' => 'inquiry_log' ]; $result = (new Generate($options))->doGenerate();