forked from Gitlink/forgeplus-react
修改导航的搜索
This commit is contained in:
parent
3453aa31eb
commit
b88c5b1faf
|
@ -0,0 +1,40 @@
|
||||||
|
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>
|
||||||
|
)
|
||||||
|
};
|
|
@ -43,7 +43,7 @@ function SiderBar() {
|
||||||
{
|
{
|
||||||
list && list.map((i,k)=>{
|
list && list.map((i,k)=>{
|
||||||
return(
|
return(
|
||||||
<li><a href={`${i.url}`} title={i.question} target="_blank">{i.question}</a></li>
|
<li key={i.question+k}><a href={`${i.url}`} title={i.question} target="_blank">{i.question}</a></li>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ import axios from 'axios';
|
||||||
import { Modal, Input, message, notification , Dropdown , Menu } from 'antd';
|
import { Modal, Input, message, notification , Dropdown , Menu } from 'antd';
|
||||||
|
|
||||||
import LoginDialog from '../../modules/login/LoginDialog';
|
import LoginDialog from '../../modules/login/LoginDialog';
|
||||||
import GotoQQgroup from '../../modal/GotoQQgroup'
|
import GotoQQgroup from '../../modal/GotoQQgroup';
|
||||||
|
import HeadSearch from '../Component/HeadSearch';
|
||||||
|
|
||||||
import '../../modules/tpm/TPMIndex.css';
|
import '../../modules/tpm/TPMIndex.css';
|
||||||
import logo from '../../modules/tpm/images/logo.png';
|
import logo from '../../modules/tpm/images/logo.png';
|
||||||
|
@ -81,35 +82,35 @@ class NewHeader extends Component {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchInput = (open,item)=>{
|
// SearchInput = (open,item)=>{
|
||||||
if(open){
|
// if(open){
|
||||||
return(
|
// return(
|
||||||
<div
|
// <div
|
||||||
onBlur={() => {
|
// onBlur={() => {
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
this.setState({
|
// this.setState({
|
||||||
openSearch:false
|
// openSearch:false
|
||||||
})
|
// })
|
||||||
}, 300)
|
// }, 300)
|
||||||
}}
|
// }}
|
||||||
>
|
// >
|
||||||
<Search placeholder="实践课程/教学课堂/实践项目/交流问答"
|
// <Search placeholder="实践课程/教学课堂/实践项目/交流问答"
|
||||||
className={`search-input mr20`}
|
// className={`search-input mr20`}
|
||||||
onSearch={(value)=>this.onGlobalSearch(value,item)}
|
// onSearch={(value)=>this.onGlobalSearch(value,item)}
|
||||||
autoFocus={true}
|
// autoFocus={true}
|
||||||
/>
|
// />
|
||||||
</div>
|
// </div>
|
||||||
)
|
// )
|
||||||
}else{
|
// }else{
|
||||||
return <i className="iconfont icon-sousuo font-18 color-grey-6 ml30" onClick={() => {
|
// return <i className="iconfont icon-sousuo font-18 color-grey-6 ml30" onClick={() => {
|
||||||
this.setState({openSearch:true})
|
// this.setState({openSearch:true})
|
||||||
}} />
|
// }} />
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
onGlobalSearch=(value,item)=>{
|
// onGlobalSearch=(value,item)=>{
|
||||||
window.location.href=`${item}?value=` + value;
|
// window.location.href=`${item}?value=` + value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
openNotification = (messge) => {
|
openNotification = (messge) => {
|
||||||
notification.open({
|
notification.open({
|
||||||
|
@ -329,7 +330,7 @@ class NewHeader extends Component {
|
||||||
{
|
{
|
||||||
list.map((item,key)=>{
|
list.map((item,key)=>{
|
||||||
return(
|
return(
|
||||||
(item.name !=="加入课堂" && item.name !=="加入开发项目") && <Menu.Item><a href={item.url}>{item.name}</a></Menu.Item>
|
(item.name !=="加入课堂" && item.name !=="加入开发项目") && <Menu.Item key={item.name+key}><a href={item.url}>{item.name}</a></Menu.Item>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -434,7 +435,7 @@ class NewHeader extends Component {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let search_url = settings && settings.common && settings.common.search;
|
// let search_url = settings && settings.common && settings.common.search;
|
||||||
let notice_url = settings && settings.common && settings.common.notice;
|
let notice_url = settings && settings.common && settings.common.notice;
|
||||||
return (
|
return (
|
||||||
<div className="newHeaders" id="nHeader">
|
<div className="newHeaders" id="nHeader">
|
||||||
|
@ -503,7 +504,8 @@ class NewHeader extends Component {
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div className="head-right">
|
<div className="head-right">
|
||||||
{search_url ? this.SearchInput(openSearch,search_url):""}
|
{/* {search_url ? this.SearchInput(openSearch,search_url):""} */}
|
||||||
|
<HeadSearch {...this.props}/>
|
||||||
{
|
{
|
||||||
current_user && (current_user.main_site || current_user.login) && (settings && settings.add && settings.add.length>0)?
|
current_user && (current_user.main_site || current_user.login) && (settings && settings.add && settings.add.length>0)?
|
||||||
<Dropdown overlay={this.addMenu(settings && settings.add)} placement="bottomRight">
|
<Dropdown overlay={this.addMenu(settings && settings.add)} placement="bottomRight">
|
||||||
|
|
Loading…
Reference in New Issue