From 46b82c7a2da78ba55277857f66fc2d29b3b99ad7 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Thu, 10 Apr 2025 17:47:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E6=96=87=E7=AB=A0=E5=88=86=E7=B1=BB=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/v1/ArticleCategory.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/v1/ArticleCategory.php b/app/admin/controller/v1/ArticleCategory.php index 2012a848..cda46432 100644 --- a/app/admin/controller/v1/ArticleCategory.php +++ b/app/admin/controller/v1/ArticleCategory.php @@ -32,7 +32,10 @@ class ArticleCategory }) ->order('sort', 'asc') ->select(); - return success('获取成功', array_to_tree($categorys, 0, 'pid', 1, false)); + if (!$categorys->isEmpty()) { + $categorys = array_to_tree($categorys, 0, 'pid', 1, false); + } + return success('获取成功', $categorys); } // 分类分页列表 @@ -54,8 +57,11 @@ class ArticleCategory }) ->order('sort', 'asc') ->select(); + if (!$category->isEmpty()) { + $category = array_to_tree($category, 0, 'pid', 1, false); + } - return success('获取成功', array_to_tree($category, 0, 'pid', 1, false)); + return success('获取成功', $category); } // 分类详情