修改整个系统导航条和管理路由相关代码
This commit is contained in:
parent
f57380b167
commit
768a44f8b3
|
@ -22,6 +22,7 @@ import { SnackbarHOC } from 'educoder';
|
||||||
import { initAxiosInterceptors } from './AppConfig'
|
import { initAxiosInterceptors } from './AppConfig'
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import configureStore from './redux/stores/configureStore';
|
import configureStore from './redux/stores/configureStore';
|
||||||
|
import { indexOf } from 'lodash';
|
||||||
const store = configureStore();
|
const store = configureStore();
|
||||||
window.marked = marked;
|
window.marked = marked;
|
||||||
const theme = createMuiTheme({
|
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 {
|
class App extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -196,7 +197,11 @@ class App extends Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
pathType: response.data.type || '404',
|
pathType: response.data.type || '404',
|
||||||
pathName: pathname,
|
pathName: pathname,
|
||||||
})
|
});
|
||||||
|
// 如果属于组织或者个人,那么存储该用户到sessionStorage中,作为判断是否为开源项目导航菜单的依据
|
||||||
|
if(['User','Organization'].includes(response.data.type)){
|
||||||
|
sessionStorage.setItem("pathname",pathname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -83,7 +83,7 @@ class IndexItem extends Component {
|
||||||
<div className="p-r-Infos">
|
<div className="p-r-Infos">
|
||||||
<div className="p-r-name">
|
<div className="p-r-name">
|
||||||
<AlignCenter>
|
<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}
|
{item.author.name}/{item.name}
|
||||||
</Link>
|
</Link>
|
||||||
{ !item.is_public && <span className="privateTag">私有</span> }
|
{ !item.is_public && <span className="privateTag">私有</span> }
|
||||||
|
|
|
@ -11,12 +11,10 @@ export default props => {
|
||||||
const main_web_site_url =localStorage.chromesetting&& JSON.parse(localStorage.chromesetting).main_web_site_url;
|
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_main_site_url =localStorage.chromesetting&& JSON.parse(localStorage.chromesetting).current_main_site_url;
|
||||||
|
|
||||||
|
|
||||||
const [current,setCurrent]=useState(JSON.parse(sessionStorage.adminRouter||'[]'));
|
const [current,setCurrent]=useState(JSON.parse(sessionStorage.adminRouter||'[]'));
|
||||||
const [title,setTitle]=useState('');
|
const [title,setTitle]=useState('');
|
||||||
|
|
||||||
function handleClick (e){
|
function handleClick (e){
|
||||||
console.log(e)
|
|
||||||
setCurrent([e.key]);
|
setCurrent([e.key]);
|
||||||
setTitle(e.item.props.title);
|
setTitle(e.item.props.title);
|
||||||
sessionStorage.setItem( 'adminRouter',JSON.stringify([e.key]));
|
sessionStorage.setItem( 'adminRouter',JSON.stringify([e.key]));
|
||||||
|
|
|
@ -581,11 +581,28 @@ class NewHeader extends Component {
|
||||||
|
|
||||||
matchpaths = (url) => {
|
matchpaths = (url) => {
|
||||||
const { match } = this.props;
|
const { match } = this.props;
|
||||||
|
let pathname=sessionStorage.pathname;
|
||||||
if(url){
|
if(url){
|
||||||
if (match.path.indexOf(url) > -1) {
|
if (url.indexOf('forums') > -1 && match.path.indexOf('forums') > -1) {
|
||||||
return true
|
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
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -727,7 +744,8 @@ class NewHeader extends Component {
|
||||||
var wl = waiLian && waiLian.length>0;
|
var wl = waiLian && waiLian.length>0;
|
||||||
return (
|
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' }}>
|
<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>
|
</li>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
.head-nav ul#header-nav li:hover a, .head-nav ul#header-nav li.active a{
|
.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{
|
.head-nav ul#header-nav li.active a::after{
|
||||||
content: "";
|
content: "";
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height:2px;
|
height:2px;
|
||||||
background-color: #1484EF;
|
background-color: #466AFF;
|
||||||
left:0px;
|
left:0px;
|
||||||
bottom: 12px;
|
bottom: 12px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
.login-box{
|
.login-box{
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
|
Loading…
Reference in New Issue