61 lines
2.5 KiB
JavaScript
61 lines
2.5 KiB
JavaScript
import React , { useState , useEffect } from 'react';
|
|
import { Menu } from 'antd';
|
|
import banner from '../img/mainbanner.png'
|
|
import { Link } from 'react-router-dom';
|
|
import { tempConfig } from '../tempInfo';
|
|
|
|
|
|
|
|
function PublicBanner(props){
|
|
const [ key , setKey ] = useState("1");
|
|
const { deptId } = props.match.params;
|
|
const { pathname } = props.history.location;
|
|
const { data , adminUrl } = props;
|
|
const temp = props.pathName
|
|
|
|
|
|
useEffect(()=>{
|
|
if(pathname){
|
|
const info = /[A-Za-z0-9]{0,}\/news/g;
|
|
const infodetail = /[A-Za-z0-9]{0,}\/newdetail/g;
|
|
const project = /[A-Za-z0-9]{0,}\/projects/g;
|
|
const vip = /[A-Za-z0-9]{0,}\/VIP/g;
|
|
if(pathname === `/${temp}/${deptId}`){
|
|
setKey("1");
|
|
}
|
|
else if(project.test(pathname)){
|
|
setKey("2");
|
|
}
|
|
else if(info.test(pathname) || infodetail.test(pathname)){
|
|
setKey("4");
|
|
}
|
|
else if(vip.test(pathname)){
|
|
setKey("6");
|
|
}
|
|
}
|
|
},[pathname])
|
|
|
|
return(
|
|
<div className="in_banner" style={{backgroundImage:`url(${(data && data.bannerList && data.bannerList.split(",")[0]) || banner})`}}>
|
|
{
|
|
data &&
|
|
<div>
|
|
<p className="main_t">{data.mainTitle}</p>
|
|
<p className="sub_t">{data.subTitle}</p>
|
|
</div>
|
|
}
|
|
<div className="bannerMenus">
|
|
<Menu mode={"horizontal"} selectedKeys={[key]}>
|
|
<Menu.Item key={"1"}><Link to={`/${temp}/${deptId}`}><img src={require(`../img/${temp}Menu1.png`)} alt="" width="29px"/>首页</Link></Menu.Item>
|
|
<Menu.Item key={"2"}><Link to={`/${temp}/${deptId}/projects`}><img src={require(`../img/${temp}Menu2.png`)} alt="" width="34px"/>开源项目</Link></Menu.Item>
|
|
{/* <Menu.Item key={"3"}><img src={Menu3} alt="" width="33px"/>资源发布</Menu.Item> */}
|
|
<Menu.Item key={"4"}><Link to={`/${temp}/${deptId}/news`}><img src={require(`../img/${temp}Menu4.png`)} alt="" width="32px"/>{ tempConfig[temp].mainTitle }</Link></Menu.Item>
|
|
{/* <Menu.Item key={"5"}><img src={Menu5} alt="" width="27px"/>Sig小组</Menu.Item> */}
|
|
<Menu.Item key={"6"}><Link to={`/${temp}/${deptId}/VIP`}><img src={require(`../img/${temp}Menu6.png`)} alt="" width="36px"/>{ tempConfig[temp].member }</Link></Menu.Item>
|
|
{ adminUrl && <Menu.Item key={"7"}><a onClick={()=>{window.location.href=adminUrl}}><img src={require(`../img/${temp}Menu7.png`)} alt="" width="34px"/>后台管理</a></Menu.Item> }
|
|
</Menu>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
export default PublicBanner; |