作者 lyh
@@ -562,15 +562,30 @@ class ProjectUpdate extends Command @@ -562,15 +562,30 @@ class ProjectUpdate extends Command
562 $url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]); 562 $url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]);
563 $data = curl_c($url); 563 $data = curl_c($url);
564 if (isset($data['code']) && $data['code'] == 200) { 564 if (isset($data['code']) && $data['code'] == 200) {
  565 + //判断分类里面是否存在自定义模块路由
  566 + $is_exist = 0;
  567 + if ($data['data']['category'] ?? []) {
  568 + foreach ($data['data']['category'] as $vc) {
  569 + $c_route = $this->get_url_route($vc['url'] ?? '');
  570 + if ($c_route == $custom_info['route']) {
  571 + $is_exist = 1;
  572 + }
  573 + }
  574 + }
  575 + if ($is_exist) {
  576 + //存在,无需添加自定义模块路由为分类路由
  577 + $category = $data['data']['category'];
  578 + } else {
  579 + //不存在,需要添加自定义模块路由为分类路由
565 $category = [ 580 $category = [
566 [ 581 [
567 'id' => 0, 582 'id' => 0,
568 'name' => $custom_info['route'], 583 'name' => $custom_info['route'],
569 'url' => '/' . $custom_info['route'], 584 'url' => '/' . $custom_info['route'],
570 - 'parent' => 0,  
571 - 'children' => $data['data']['category'] ?? [] 585 + 'parent' => $data['data']['category'] ?? []
572 ] 586 ]
573 ]; 587 ];
  588 + }
574 $this->category_custom_insert($project_id, $custom_info['id'], $category, 0); 589 $this->category_custom_insert($project_id, $custom_info['id'], $category, 0);
575 590
576 $count = $data['data']['count'] ?? 0; 591 $count = $data['data']['count'] ?? 0;