forked from Gitlink/forgeplus-react
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
import React, { useState } from "react";
|
|
import { Input ,notification} from "antd";
|
|
|
|
const { Search } = Input;
|
|
export default ({history}) => {
|
|
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)
|
|
}}
|
|
>
|
|
<Search placeholder="请输入项目关键字"
|
|
className={`search-input mr20`}
|
|
onSearch={onGlobalSearch}
|
|
autoFocus={true}
|
|
/>
|
|
</div>
|
|
:
|
|
<i className="iconfont icon-sousuo font-18 color-grey-6 ml30" onClick={() => {
|
|
setOpenSearch(true)
|
|
}} />
|
|
}
|
|
</React.Fragment>
|
|
)
|
|
};
|