LinkAfterLogin

dev_hjm
hjm 6 years ago
parent 8960cc6216
commit 5fdbbcd319

@ -0,0 +1,23 @@
import React, { Component } from 'react';
// 登录后才能跳转
class LinkAfterLogin extends Component {
constructor(props) {
super(props);
}
checkAuth = () => {
if (this.props.checkIfLogin()) {
this.props.history.push(this.props.to)
} else {
this.props.showLoginDialog()
}
}
render() {
return(
<a {...this.props} onClick={this.checkAuth}>{this.props.children}</a>
)
}
}
export default LinkAfterLogin;

@ -36,6 +36,7 @@ export { ModalHOC } from './components/ModalHOC'
export { SetAppModel } from './components/SetAppModel'
export { default as LinkAfterLogin } from './components/LinkAfterLogin'
export { default as Cropper } from './components/Cropper'
export { default as ConditionToolTip } from './components/ConditionToolTip'
export { default as DragValidator } from './components/DragValidator'

@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
import classNames from 'classnames'
import { getImageUrl, toPath } from 'educoder'
import { getImageUrl, toPath, LinkAfterLogin } from 'educoder'
import match_adImg from '../../images/ad/match_ad.jpg'
const $ = window.$
@ -58,7 +58,7 @@ class RightMyPublish extends Component {
</img>
</div>
<Link to={'/forums/new'} className="sendMyQuestion edu-default-btn edu-blueback-btn edu-txt-center font-16 mb30">发布话题</Link>
<LinkAfterLogin {...this.props} to={'/forums/new'} className="sendMyQuestion edu-default-btn edu-blueback-btn edu-txt-center font-16 mb30">发布话题</LinkAfterLogin>
{/*<p className="edu-txt-center font-16">
<span>我的发布</span><br/>
<Link to={`/forums/categories/my_published`} className="color-blue">{my_memos_count}</Link>

@ -9,6 +9,7 @@ import { getUrl } from 'educoder'
import axios from 'axios';
import './TPMIndex.css'
import LoginDialog from '../login/LoginDialog';
import Trialapplication from "../login/Trialapplication";
// import "antd/dist/antd.css";
// import '../../css/educoder/edu-common.css'
@ -74,6 +75,8 @@ export function TPMIndexHOC(WrappedComponent) {
Headertop:undefined,
Footerdown:undefined,
coursedata: {},
isRender: false
}
}
@ -286,9 +289,22 @@ export function TPMIndexHOC(WrappedComponent) {
}).catch((error) => {
console.log(error)
})
}
hideLoginDialog = () => {
this.setState({
isRender: false
})
}
showLoginDialog = () => {
this.setState({
isRender: true
})
}
checkIfLogin = () => {
return this.state.current_user && this.state.current_user.login != ''
}
render() {
let{Headertop,Footerdown}=this.state;
let{Headertop,Footerdown, isRender}=this.state;
const common = {
isSuperAdmin:this.isSuperAdmin,
isAdminOrCreator:this.isAdminOrCreator,
@ -299,11 +315,18 @@ export function TPMIndexHOC(WrappedComponent) {
isAdminOrStudent: this.isAdminOrStudent,
isNotMember: this.isNotMember,
isUserid:this.state.coursedata&&this.state.coursedata.userid,
fetchUser: this.fetchUser
fetchUser: this.fetchUser,
showLoginDialog: this.showLoginDialog,
checkIfLogin: this.checkIfLogin,
}
return (
<div>
{isRender===true ? <LoginDialog
Modifyloginvalue={()=>this.hideLoginDialog()}
{...this.state}
{...this.props}
/> : ""}
<SiderBar Headertop={Headertop}/>
{/* 注释掉了1440 影响到了手机屏幕的展示 */}
<style>{

Loading…
Cancel
Save