LiuJ 2 месяцев назад
Родитель
Сommit
af09b2bfa6
1 измененных файлов с 10 добавлено и 9 удалено
  1. 10 9
      app/JsonRpc/ClientService.php

+ 10 - 9
app/JsonRpc/ClientService.php

@@ -151,7 +151,7 @@ class ClientService implements ClientServiceInterface
                             continue;
                         };
                         var_dump($componentData, '----------------componentData-------------');
-                        if(is_array($componentData) && count($componentData) > 1 && !isset($componentData['level'])){
+                        if (is_array($componentData) && count($componentData) > 1 && !isset($componentData['level'])) {
                             foreach ($componentData as $k1 => $v1) {
                                 // $v1['category_id'] = $v1['category_id'];
                                 $category_id = $v1['category_id'] ?? 0;
@@ -287,9 +287,9 @@ class ClientService implements ClientServiceInterface
                                 $componetList[$key]['componentData']['data'][$k1]['pinyin'] = $websiteInfoIndexed[$category_id]->pinyin ?? 'aliasnull' . $category_id;
                                 $componetList[$key]['componentData']['data'][$k1]['category_id'] = $category_id;
                                 $componetList[$key]['componentData']['data'][$k1]['textnum'] = $textArticles ?? [];
-                                $componetList[$key]['componentData']['data'][$k1]['imgnum'] = $imgArticles ?? []; 
+                                $componetList[$key]['componentData']['data'][$k1]['imgnum'] = $imgArticles ?? [];
                             }
-                        }else{
+                        } else {
                             $category_id = $componentData['category_id'] ?? 0;
                             //此处应该有值
                             $imgSize = $componentData['imgSize'];
@@ -429,9 +429,9 @@ class ClientService implements ClientServiceInterface
                         // $page = $componentData['page'];
                         // $pageSize = $componentData['pageSize'];
                         // $listType = $componentData['listType'];
-                        
+
                         //将查询到的数据放到componentData里
-                       
+
                         //判断child
                         var_dump($child_id, '--------child_id---');
                         if ($child_id > 0) {
@@ -1171,13 +1171,14 @@ class ClientService implements ClientServiceInterface
 }
 class bt_api
 {
-    private $BT_KEY = env('BT_KEY', 'RN0wTXLHpKKBXXxyDJoovHMpBhyLVFWZ');  //接口密钥
-    private $BT_PANEL = env('BT_PANEL', 'http://192.168.1.234:18888');       //面板地址
+    private $BT_KEY;   // 只声明,不初始化
+    private $BT_PANEL; // 只声明,不初始化
     //如果希望多台面板,可以在实例化对象时,将面板地址与密钥传入
     public function __construct($bt_panel = null, $bt_key = null)
     {
-        if ($bt_panel) $this->BT_PANEL = $bt_panel;
-        if ($bt_key) $this->BT_KEY = $bt_key;
+        // 在构造函数中使用 env() 初始化
+        $this->BT_KEY = $bt_key ?? env('BT_KEY', 'RN0wTXLHpKKBXXxyDJoovHMpBhyLVFWZ');
+        $this->BT_PANEL = $bt_panel ?? env('BT_PANEL', 'http://192.168.1.234:18888');
     }
 
     //示例取面板日志