优化搜索显示效果以及同步搜索内容到地址栏

This commit is contained in:
谢思 2024-09-12 09:39:49 +08:00
parent 1e4bb463a3
commit c3ab059ccb
3 changed files with 15 additions and 9 deletions

View File

@ -2,6 +2,7 @@ import React from 'react';
import './index.scss';
import dianzan from './image/dianzan.png';
import fork from './image/fork.png';
import RenderHtml from '../../components/render-html';
export default (props) => {
const { list } = props;
@ -25,7 +26,7 @@ export default (props) => {
</p>}
</div >
<p className="search-item-content" dangerouslySetInnerHTML={{ __html: item.content }}></p>
{item.content && <RenderHtml className="break_word_comments imageLayerParent search-item-content hide-2 task-hide mb15" value={item.content} />}
<div>{item.updateTime}</div>
</div>
)

View File

@ -64,6 +64,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
setTerm(val);
setPage(1);
setForcesearch(!forcesearch);
history.push(`/search?value=${val}`);
}
function searchDataList() {
@ -178,8 +179,6 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
size="large"
onSearch={searchFun}
className={{ 'global-search': true, "required-search": !searchValue }}
value={searchValue}
onChange={(e) => { setSearchValue(e.target.value) }}
ref={(el) => setRef(el)}
/>
{!searchValue && <span className="ant-form-explain">请输入搜索关键字</span>}
@ -208,7 +207,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
创建时间{iconSwitch(orderBy === "createTimeDesc" ? "desc" : orderBy === "createTimeAsc" ? "asc" :"")}
</li>
</ul>
<p>{`找到${totalType1}条结果`}</p>
<p className='mb15'>{`找到${totalType1}条结果`}</p>
<ItemList
list={dataList}
/>
@ -228,7 +227,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
<TabPane tab={`帖子(${totalType2}`} key="2">
<div className="search-content">
<p>{`找到${totalType2}条结果`}</p>
<p className='mb15'>{`找到${totalType2}条结果`}</p>
<ItemList
list={dataList}
/>
@ -285,7 +284,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
<TabPane tab={`疑修(${totalType5}`} key="5">
<div className="search-content">
<p>{`找到${totalType5}条结果`}</p>
<p className='mb15'>{`找到${totalType5}条结果`}</p>
<ItemList
list={dataList}
/>

View File

@ -48,7 +48,7 @@
.search-content {
width: 1200px;
margin: 1.5vw auto;
p{
.search-item-title{
margin-bottom: .75em !important;
}
}
@ -85,12 +85,18 @@
&:hover{
color: #466aff;
}
span{
.highlightByGitlinkSearch{
color: #466aff;
}
}
.search-item-content{
span{
-webkit-line-clamp: 5;
color: rgba(0, 0, 0, 0.65);
font-size: 14px;
a{
color: rgba(0, 0, 0, 0.65);
}
.highlightByGitlinkSearch{
color: #466aff;
}
}