2021-06-03 10:00:24 +08:00
|
|
|
import React, { useState } from "react";
|
|
|
|
|
import { Input ,notification} from "antd";
|
|
|
|
|
|
|
|
|
|
const { Search } = Input;
|
2023-04-07 11:11:15 +08:00
|
|
|
export default ({history,searchUrl}) => {
|
2021-06-03 10:00:24 +08:00
|
|
|
const [openSearch, setOpenSearch] = useState(false);
|
|
|
|
|
|
|
|
|
|
function onGlobalSearch(value) {
|
|
|
|
|
history.push('/search?value=' + value);
|
|
|
|
|
// window.location.href = `search?value=` + value;
|
|
|
|
|
// history.push({
|
|
|
|
|
// pathname:'/search',
|
|
|
|
|
// state:value
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
{
|
|
|
|
|
openSearch ?
|
|
|
|
|
<div
|
|
|
|
|
onBlur={() => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
setOpenSearch(false)
|
|
|
|
|
}, 500)
|
|
|
|
|
}}
|
|
|
|
|
>
|
2021-06-10 17:05:49 +08:00
|
|
|
<Search placeholder="请输入搜索关键字"
|
2021-06-03 10:00:24 +08:00
|
|
|
className={`search-input mr20`}
|
|
|
|
|
onSearch={onGlobalSearch}
|
|
|
|
|
autoFocus={true}
|
2021-06-11 15:28:40 +08:00
|
|
|
style={{width:'260px'}}
|
2021-06-03 10:00:24 +08:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
:
|
2023-04-07 11:58:55 +08:00
|
|
|
<a href={`${searchUrl}?value=`}><i className="iconfont icon-sousuo font-18 ml15 mr15 color-white" /></a>
|
2021-06-03 10:00:24 +08:00
|
|
|
}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
};
|