diff --git a/app/controller/frontend/SearchController.php b/app/controller/frontend/SearchController.php index 4f50b90..97bd38e 100644 --- a/app/controller/frontend/SearchController.php +++ b/app/controller/frontend/SearchController.php @@ -114,6 +114,10 @@ class SearchController extends BaseController if (isset($sets['product'][$contentId])) { return ['product', '产品']; } + // 企业视频优先于新闻:交互同视频教程,类型仍显示新闻 + if (isset($sets['news_video'][$contentId])) { + return ['video', '新闻']; + } if (isset($sets['news'][$contentId])) { return ['news', '新闻']; } @@ -184,6 +188,10 @@ class SearchController extends BaseController $productContentIds = $this->getContentIdsByCategoryIds($this->getCategoryTreeIds(self::PRODUCT_CATE_ID)); $newsContentIds = $this->getContentIdsByCategoryIds($this->getCategoryTreeIds(self::NEWS_CATE_ID)); $faqContentIds = $this->getContentIdsByCategoryIds($this->getCategoryTreeIds(self::FAQ_CATE_ID)); + $newsVideoCateId = uiId('news_video'); + $newsVideoContentIds = $newsVideoCateId > 0 + ? $this->getContentIdsByCategoryIds($this->getCategoryTreeIds($newsVideoCateId)) + : []; // 其他 = 下载中心 + 视频 + 公告 $downloadContentIds = $this->getContentIdsByCategoryIds($this->getCategoryTreeIds(self::DOWNLOAD_CATE_ID)); @@ -236,8 +244,10 @@ class SearchController extends BaseController $downloadIdSet = array_flip($downloadContentIds); $videoIdSet = array_flip($videoContentIds); $announceIdSet = array_flip($announceContentIds); + $newsVideoIdSet = array_flip($newsVideoContentIds); $kindSets = [ 'product' => $productIdSet, + 'news_video' => $newsVideoIdSet, 'news' => $newsIdSet, 'faq' => $faqIdSet, 'download' => $downloadIdSet, @@ -255,7 +265,7 @@ class SearchController extends BaseController ->paginate([ 'page' => $param['page'] ?? 1, 'list_rows' => $param['limit'] ?? 10, - ])->each(function (&$item) use ($type, $tabKindMap, $kindSets) { + ])->each(function (&$item) use ($type, $tabKindMap, $kindSets, $newsVideoIdSet) { $row = $item->toArray(); if (!empty($row['category'])) { $item['category'] = $row['category']; @@ -269,14 +279,20 @@ class SearchController extends BaseController $item['content'] = $rawContent !== '' ? htmlspecialchars_decode((string)$rawContent) : ''; $item['sr_date'] = $this->formatSearchDate($row['publish_time'] ?? ($row['create_time'] ?? '')); + $contentId = (int)($row['id'] ?? 0); if (isset($tabKindMap[$type])) { [$kind, $name] = $tabKindMap[$type]; } else { - [$kind, $name] = $this->resolveSearchKind((int)($row['id'] ?? 0), $kindSets); + [$kind, $name] = $this->resolveSearchKind($contentId, $kindSets); if ($kind === 'content' && !empty($row['category'][0]['title'])) { $name = $row['category'][0]['title']; } } + // 企业视频:交互同视频教程,类型名仍为新闻 + if (isset($newsVideoIdSet[$contentId])) { + $kind = 'video'; + $name = '新闻'; + } $item['sr_kind'] = $kind; $item['sr_tab_name'] = $name; });