修改搜索的功能及图标

This commit is contained in:
何童崇 2021-06-09 19:47:14 +08:00
parent f93df6069c
commit 681d0b17e3
2 changed files with 41 additions and 7 deletions

BIN
public/favicon.ico Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -12,14 +12,17 @@ const { TabPane } = Tabs;
// const https = 'http://192.168.0.77:8081'; //
// const https = 'http://192.168.31.104:8081'; //
const https='http://106.75.31.211:58081';
// const https='http://106.75.31.211:58081';
const https = 'https://test-statistics.trustie.net';
const GlobalSearch = ({ location, showNotification }) => {
const GlobalSearch = ({ location, showNotification, history }) => {
const size = 10;
let defaultValue = decodeURI(location.search.split("=")[1] || "");
const [term, setTerm] = useState(defaultValue);
const [searchValue, setSearchValue] = useState(defaultValue);
const [type, setType] = useState(1);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
@ -31,6 +34,7 @@ const GlobalSearch = ({ location, showNotification }) => {
const [totalType2, setTotalType2] = useState(0);
const [totalType3, setTotalType3] = useState(0);
const [totalType4, setTotalType4] = useState(0);
const [totalType5, setTotalType5] = useState(0);
useEffect(() => {
@ -50,6 +54,10 @@ const GlobalSearch = ({ location, showNotification }) => {
function searchDataList() {
const url = https + '/search';
if (!term) {
showNotification('请输入关键字');
return;
}
axios.defaults.withCredentials = true;
axios.get(url, {
params: {
@ -72,6 +80,8 @@ const GlobalSearch = ({ location, showNotification }) => {
setTotalType3(item.count);
} else if (item.type == 4) {
setTotalType4(item.count);
} else if (item.type == 5) {
setTotalType5(item.count);
}
}
} else if (res && res.data) {
@ -96,7 +106,11 @@ const GlobalSearch = ({ location, showNotification }) => {
setPage(1);
}
useEffect(() => {
history.listen(historyLocation => {
setSearchValue(historyLocation.search.split("=")[1] || "");
})
}, [history]);
return (
<div className="suit-main clearfix">
@ -110,7 +124,8 @@ const GlobalSearch = ({ location, showNotification }) => {
size="large"
onSearch={searchFun}
className="global-search"
defaultValue={term}
value={searchValue}
onChange={(e) => { setSearchValue(e.target.value) }}
/>
</Col>
</Row>
@ -134,11 +149,11 @@ const GlobalSearch = ({ location, showNotification }) => {
total={total}
showTotal={total => `${total}`}
/>
: <Nodata _html="暂无数据" className="no-data-box"/>
: <Nodata _html="暂无数据" className="no-data-box" />
}
</TabPane>
{/* <TabPane tab={`${totalType2}`} key="2">
<TabPane tab={`帖子(${totalType2}`} key="2">
<div className="search-content">
<p>{`找到${totalType2}条结果`}</p>
<ItemList
@ -157,7 +172,7 @@ const GlobalSearch = ({ location, showNotification }) => {
}
</TabPane>
<TabPane tab={`众包任务(${totalType3}`} key={3}>
{/* <TabPane tab={`${totalType3}`} key={3}>
<div className="search-content">
<p>{`找到${totalType3}条结果`}</p>
<ItemList
@ -194,6 +209,25 @@ const GlobalSearch = ({ location, showNotification }) => {
/> : <Nodata _html="暂无数据" />
}
</TabPane> */}
<TabPane tab={`易修(${totalType5}`} key="5">
<div className="search-content">
<p>{`找到${totalType5}条结果`}</p>
<ItemList
list={dataList}
/>
</div>
{
dataList.length ?
<Pagination
showQuickJumper={dataList.length > size}
onChange={(page) => { setPage(page) }}
current={page}
total={total}
showTotal={total => `${total}`}
/> : <Nodata _html="暂无数据" />
}
</TabPane>
</Tabs>
</div>