Эх сурвалжийг харах

ai会话-给模板添加导航

FengR 1 сар өмнө
parent
commit
7126fc6b3b

+ 17 - 4
app/JsonRpc/PublicRpcService.php

@@ -4675,11 +4675,24 @@ class PublicRpcService implements PublicRpcServiceInterface
         $websiteServer = new \App\JsonRpc\WebsiteService();
         $all_cate_data = $websiteServer->getWebsiteModelCategory($cate_column);
         $all_cate = $all_cate_data['data'] ?? [];
-        return Result::success($all_cate);
+        // return Result::success($all_cate);
 
-        if(count($all_cate) == 0){
+        if (count($all_cate) == 0) {
             return Result::error('栏目不存在!');
         }
+
+        // 将 Collection 转为数组
+        $all_cate = $all_cate->toArray();
+        $del_catid = 0;
+        foreach ($all_cate as $k => $v) {
+            $cat_arr_id = json_decode($v['category_arr_id'],true) ?? [];
+            if (!empty($v['web_url']) || $v['type'] != 1 || $v['pid'] == $del_catid) {
+                $del_catid = $v['category_id'] ?? '';
+                unset($all_cate[$k]);
+            }
+        }
+        $all_cate = array_values($all_cate);
+        // return Result::success($all_cate);
         $componentList = array_column($template_index,'componentList');
         $componentData = [];
         $cat_key = 0;
@@ -4688,7 +4701,7 @@ class PublicRpcService implements PublicRpcServiceInterface
             if(count($item) == 1 && isset($item[0]['componentData']['level']) && (empty($v['componentData']['level']) || $v['componentData']['level'] == "")){
                 // if(isset($item[0]) && !empty($item[0])){
                     $componentList[$key][0]['componentData']['name'] = $all_cate[$cat_key]['alias'] ?? '';
-                    $componentList[$key][0]['componentData']['category_arr'] = $all_cate[$cat_key]['category_arr_id'] ?? '';
+                    $componentList[$key][0]['componentData']['category_arr'] = json_decode($all_cate[$cat_key]['category_arr_id'],true) ?? '';
                     $componentList[$key][0]['componentData']['category_id'] = $all_cate[$cat_key]['category_id'] ?? '';
                     $cat_key++;
                     $template_index[$key]['componentList'] = $componentList[$key] ?? [];
@@ -4700,7 +4713,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                     $componentList[$key][$k] = $v ?? [];
                     if(isset($v['componentData']['level']) && (empty($v['componentData']['level']) || $v['componentData']['level'] == "")){
                         $componentList[$key][$k]['componentData']['name'] = $all_cate[$cat_key]['alias'] ?? '';
-                        $componentList[$key][$k]['componentData']['category_arr'] = $all_cate[$cat_key]['category_arr_id'] ?? '';
+                        $componentList[$key][$k]['componentData']['category_arr'] = json_decode($all_cate[$cat_key]['category_arr_id'],true) ?? '';
                         $componentList[$key][$k]['componentData']['category_id'] = $all_cate[$cat_key]['category_id'] ?? '';
                         $cat_key++;
                         $template_index[$key]['componentList'][$k] = $componentList[$key][$k] ?? [];