From bc7b9cecbdf8eddaef6c124ae04f878bbaa7d488 Mon Sep 17 00:00:00 2001 From: peijunlei Date: Tue, 8 Sep 2026 13:18:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(search):=20=E6=B7=BB=E5=8A=A0=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E8=A7=86=E9=A2=91=E6=94=AF=E6=8C=81=E8=87=B3=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/frontend/SearchController.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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; });