This commit is contained in:
675061370@qq.com
2024-09-14 22:34:10 +08:00
parent 128081c297
commit c14b939e3d
2 changed files with 14 additions and 3 deletions
+7
View File
@@ -754,11 +754,18 @@ function filterAndExtractWords(array $result)
*/ */
function highlightKeywords($title, $searchTitle) function highlightKeywords($title, $searchTitle)
{ {
$originalTitle = $title; // 保存原始标题
// 使用正则表达式来高亮所有关键词 // 使用正则表达式来高亮所有关键词
foreach ($searchTitle as $keyword) { foreach ($searchTitle as $keyword) {
$title = preg_replace('/(' . preg_quote($keyword, '/') . ')/i', '<span>$1</span>', $title); $title = preg_replace('/(' . preg_quote($keyword, '/') . ')/i', '<span>$1</span>', $title);
} }
// 如果有关键词被高亮,添加<p>标签
if ($title !== $originalTitle) {
$title = '<p>' . $title . '</p>';
}
return $title; return $title;
} }
+7 -3
View File
@@ -477,8 +477,12 @@ a:hover {
font-weight: bold; font-weight: bold;
padding-right: 42px; padding-right: 42px;
padding-bottom: 4px; padding-bottom: 4px;
color: var(--theme-theme);
} }
.listBox .left .list .item .title span{ .listBox .left .list .item .title p{
color: var(--theme-color);
}
.listBox .left .list .item .title p span{
color: var(--theme-theme); color: var(--theme-theme);
} }
.listBox .left .list .item .btns{ .listBox .left .list .item .btns{
@@ -489,11 +493,11 @@ a:hover {
.listBox .left .list .item .btns .btn{ .listBox .left .list .item .btns .btn{
position: relative; position: relative;
margin-right: 35px; margin-right: 35px;
color: var(--theme-theme);
opacity: .95;
cursor: pointer; cursor: pointer;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
font-weight: 500;
color: var(--theme-color);
} }
.listBox .left .list .item .btns .btn .iconfont{ .listBox .left .list .item .btns .btn .iconfont{
font-size: 18px; font-size: 18px;