react头部登录判断

dev_aliyun
杨树明 6 years ago
parent 737dbdd341
commit a60f4332b3

@ -64,8 +64,8 @@ gem 'elasticsearch-rails'
gem 'oauth2'
# xlsx
# gem 'axlsx', '3.0.0.pre'
# gem 'axlsx_rails', '0.3.0'
gem 'axlsx', '3.0.0.pre'
gem 'axlsx_rails', '0.3.0'
# state machine
gem 'aasm'

@ -257,6 +257,23 @@ class NewHeader extends Component {
localStorage.setItem('competition_uid', true);
}
NewCoursesAndShixuns=(sum)=>{
if(this.props.current_user&&this.props.current_user.login=== ""){
window.location.href = "/login";
}else{
if(sum===1){
window.location.href = "/courses/new";
}else if(sum===2){
window.location.href = "/shixuns/new";
}else if(sum===3){
window.location.href = "/paths/new";
}else if(sum===4){
window.location.href = "/projects/new";
}
}
}
render() {
let {careerslist,isLogin,current_user,ImageUrl,ecUrl,ImageUrlType,project_packages_url} = this.state;
// const isLogin = isLogintype; // 这里不会出现未登录的情况,服务端在服务端路由时发现如果是未登录,则跳转到登录页了。
@ -291,7 +308,7 @@ class NewHeader extends Component {
console.log(this.props.current_user)
console.log(this.props.current_user&&this.props.current_user.login=== "")
console.log(this.state.current_user)
// console.log(match.path.startsWith("/ec_courses"))
return (
@ -460,10 +477,10 @@ class NewHeader extends Component {
<div className="edu-menu-list" style={{top: '60px',width:"240px"}}>
<div className="overPart"></div>
<ul className="fl with50 edu-txt-center pr ul-leftline">
<li><a href="/courses/new">新建课堂</a></li>
<li><a href="/shixuns/new">新建实训</a></li>
<li><a href="/paths/new">新建实践课程</a></li>
<li><a href="/projects/new">新建项目</a></li>
<li><a onClick={()=>this.NewCoursesAndShixuns(1)}>新建课堂</a></li>
<li><a onClick={()=>this.NewCoursesAndShixuns(2)}>新建实训</a></li>
<li><a onClick={()=>this.NewCoursesAndShixuns(3)}>新建实践课程</a></li>
<li><a onClick={()=>this.NewCoursesAndShixuns(4)}>新建项目</a></li>
</ul>
<ul className="fl with50 edu-txt-center">
<li>

Loading…
Cancel
Save