修改整个系统导航条和管理路由相关代码

This commit is contained in:
何童崇 2022-03-01 15:52:02 +08:00
parent f57380b167
commit 768a44f8b3
5 changed files with 33 additions and 11 deletions

View File

@ -22,6 +22,7 @@ import { SnackbarHOC } from 'educoder';
import { initAxiosInterceptors } from './AppConfig'
import { Provider } from 'react-redux';
import configureStore from './redux/stores/configureStore';
import { indexOf } from 'lodash';
const store = configureStore();
window.marked = marked;
const theme = createMuiTheme({
@ -145,7 +146,7 @@ const Managements = Loadable({
// })
// 此处仅维护前端可能的一级路由,不用进行项目或者组织判断的字段。
const keyWord = ["explore", "settings", "setting", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search", "organize", "login", "register", "resetPassword", "aboutus","educoder","task","notice"];
const keyWord = ["explore", "settings", "setting", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search", "organize", "login", "register", "resetPassword", "aboutus","educoder","task","notice","managements","expert",];
class App extends Component {
constructor(props) {
@ -196,7 +197,11 @@ class App extends Component {
this.setState({
pathType: response.data.type || '404',
pathName: pathname,
})
});
// 如果属于组织或者个人那么存储该用户到sessionStorage中作为判断是否为开源项目导航菜单的依据
if(['User','Organization'].includes(response.data.type)){
sessionStorage.setItem("pathname",pathname);
}
}
});
}else{

View File

@ -83,7 +83,7 @@ class IndexItem extends Component {
<div className="p-r-Infos">
<div className="p-r-name">
<AlignCenter>
<Link to={`/${item.author.login}/${item.identifier}`} target="_blank" title={`${item.author.name}/${item.name}`} className="color-grey-3 font-18 task-hide " style={{maxWidth: 470 }}>
<Link to={`/${item.author.login}/${item.identifier}`} title={`${item.author.name}/${item.name}`} className="color-grey-3 font-18 task-hide " style={{maxWidth: 470 }}>
{item.author.name}/{item.name}
</Link>
{ !item.is_public && <span className="privateTag">私有</span> }

View File

@ -11,12 +11,10 @@ export default props => {
const main_web_site_url =localStorage.chromesetting&& JSON.parse(localStorage.chromesetting).main_web_site_url;
const current_main_site_url =localStorage.chromesetting&& JSON.parse(localStorage.chromesetting).current_main_site_url;
const [current,setCurrent]=useState(JSON.parse(sessionStorage.adminRouter||'[]'));
const [title,setTitle]=useState('');
function handleClick (e){
console.log(e)
setCurrent([e.key]);
setTitle(e.item.props.title);
sessionStorage.setItem( 'adminRouter',JSON.stringify([e.key]));

View File

@ -581,11 +581,28 @@ class NewHeader extends Component {
matchpaths = (url) => {
const { match } = this.props;
let pathname=sessionStorage.pathname;
if(url){
if (match.path.indexOf(url) > -1) {
if (url.indexOf('forums') > -1 && match.path.indexOf('forums') > -1) {
return true
}else {
// 开源项目,路由改版后,比较麻烦,因此使用多个进行判断
} else if (url.indexOf('explore') > -1 && match.path.indexOf('explore') > -1) {
return true
// 开源项目,路由改版后,比较麻烦,因此使用多个进行判断
} else if (url.indexOf('explore') > -1 && match.url.indexOf(pathname) > -1) {
return true
// 公告
} else if (url.indexOf('/notice') > -1 && match.path.indexOf('/notice') > -1) {
return true
// 创客
} else if (url.indexOf('/task') > -1 && match.path.indexOf('/task') > -1) {
return true
// 管理
} else if (url.indexOf('/managements') > -1 && match.path.indexOf('/managements') > -1) {
return true
} else if (['http://117.50.100.12:8080','https://osredm.com','http://111.8.36.180:8000','http://localhost:3007'].includes(url) && match.path === '/') {
return true
} else {
return false
}
}
@ -727,7 +744,8 @@ class NewHeader extends Component {
var wl = waiLian && waiLian.length>0;
return (
<li key={key} onClick={() => this.headtypesonClick(item.link, true)} className={`${this.matchpaths(item.link) === true ? 'pr active' : 'pr'}`} style={!is_hidden ? { display: 'flex' } : { display: 'none' }}>
<a href={new_link} target={wl ? "_self":"_blank"}>{item.name}</a>
<a href={new_link} >{item.name}</a>
{/* target={wl ? "_self":"_blank"} */}
</li>
)
})

View File

@ -1,14 +1,15 @@
.head-nav ul#header-nav li:hover a, .head-nav ul#header-nav li.active a{
color: #1484EF;
color: #466AFF;
}
.head-nav ul#header-nav li.active a::after{
content: "";
width: 100%;
height:2px;
background-color: #1484EF;
background-color: #466AFF;
left:0px;
bottom: 12px;
position: absolute;
margin-left: 0;
}
.login-box{
font-size: 15px;