forked from Gitlink/forgeplus-react
顶部导航栏搜索框还原
This commit is contained in:
parent
4e18d13b6b
commit
fe0fab7b61
|
@ -1,21 +1,41 @@
|
|||
import React, { useState } from "react";
|
||||
import { Input} from "antd";
|
||||
import './Component.scss';
|
||||
import { Input ,notification} from "antd";
|
||||
|
||||
const { Search } = Input;
|
||||
export default ({history}) => {
|
||||
const [searchValue, setSearchValue] = useState("");
|
||||
const [openSearch, setOpenSearch] = useState(false);
|
||||
|
||||
function onGlobalSearch(e) {
|
||||
window.location.href = `/search?value=${e.target.value}`;
|
||||
function onGlobalSearch(value) {
|
||||
history.push('/search?value=' + value);
|
||||
// window.location.href = `search?value=` + value;
|
||||
// history.push({
|
||||
// pathname:'/search',
|
||||
// state:value
|
||||
// })
|
||||
}
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="headSerach aboutSubTitle" onBlur={()=>{setTimeout(() => {
|
||||
setSearchValue("");
|
||||
}, 500)}}>
|
||||
<i className = "iconfont icon-bianzu11 font-15" onClick={()=>onGlobalSearch({target:{value:searchValue}})}></i>
|
||||
<Input placeholder="请输入搜索关键字" onPressEnter={onGlobalSearch} onChange={(value)=>setSearchValue(value.target.value)} value={searchValue}></Input>
|
||||
</div>
|
||||
{
|
||||
openSearch ?
|
||||
<div
|
||||
onBlur={() => {
|
||||
setTimeout(() => {
|
||||
setOpenSearch(false)
|
||||
}, 500)
|
||||
}}
|
||||
>
|
||||
<Search placeholder="请输入搜索关键字"
|
||||
className={`search-input mr20`}
|
||||
onSearch={onGlobalSearch}
|
||||
autoFocus={true}
|
||||
style={{width:'260px'}}
|
||||
/>
|
||||
</div>
|
||||
:
|
||||
<i className="iconfont icon-sousuo font-18 ml30" onClick={() => {
|
||||
setOpenSearch(true)
|
||||
}} />
|
||||
}
|
||||
</React.Fragment>
|
||||
)
|
||||
};
|
||||
|
|
|
@ -34,14 +34,10 @@ function Login(props){
|
|||
} else {
|
||||
//判断用户是否选择【下次自动登录】
|
||||
cookie.save('autologin',values.remember);
|
||||
if(search){
|
||||
const searchParams = new URLSearchParams(search.substring(1));
|
||||
const goPage = searchParams.get("go_page");
|
||||
//意见反馈
|
||||
goPage && (window.location.href = goPage);
|
||||
return;
|
||||
}
|
||||
window.location.href = "/"+response.data.login;
|
||||
const searchParams = new URLSearchParams(search.substring(1));
|
||||
const goPage = searchParams.get("go_page");
|
||||
//意见反馈
|
||||
window.location.href = goPage ? goPage : `/${response.data.login}`
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log('error',error);
|
||||
|
|
Loading…
Reference in New Issue