dev_aliyun2
harry 5 years ago
parent 38af6a6b12
commit 670c123dea

@ -1,16 +1,15 @@
import React, { Component } from 'react';
import { Route, Link, Switch } from "react-router-dom";
import { Row, Col, Menu } from 'antd';
import { Row, Col, Menu, } from 'antd';
import Loading from '../../Loading';
import { Loadable } from 'educoder';
import TPMIndexHOC from './TPMIndexHOC';
import { SnackbarHOC } from 'educoder';
import { SnackbarHOC, Loadable } from 'educoder';
import TPMBanner from './TPMBanner';
@ -33,64 +32,12 @@ import TPMDataset from './TPMDataset';
import '../page/tpiPage.css';
//任务
// const TPMChallengeComponent = Loadable({
// loader: () => import('./TPMChallengeContainer'),
// loading: Loading,
// })
//背景知识
// const TPMPropaedeuticsComponent = Loadable({
// loader: () => import('./TPMPropaedeuticsComponent'),
// loading: Loading,
// })
//版本库
// const TPMRepositoryComponent = Loadable({
// loader: () => import('./TPMRepositoryComponent'),
// loading: Loading,
// })
// const TPMRepositoryComponent = Loadable({
// loader: () => import('./TPMRepositoryComponent'),
// loading: Loading,
// })
//合作
// const TPMCollaboratorsComponent = Loadable({
// loader: () => import('./TPMCollaboratorsContainer'),
// loading: Loading,
// })
//评论
// const TPMShixunDiscussComponent = Loadable({
// loader: () => import('./TPMShixunDiscussContainer'),
// loading: Loading,
// })
//排行版
// const TPMRanking_listComponent = Loadable({
// loader: () => import('./TPMRanking_listContainer'),
// loading: Loading,
// })
// //编辑实训
// const TPMModifysettings = Loadable({
// loader: () =>import('./modules/tpm/TPMsettings/TPMsettings'),
// loading: Loading,
// })
//新建实训
const TPMchallengesnew = Loadable({
loader: () => import('./challengesnew/TPMchallengesnew'),
loading: Loading,
})
//新建实训
// const TPMchallengesnew = Loadable({
// loader: () => import('./challengesnew/TpmTask/TpmTaskIndex'),
// loading: Loading,
// })
//新建tab2
const TPMevaluation = Loadable({
@ -98,11 +45,6 @@ const TPMevaluation = Loadable({
loading: Loading,
})
//新建tab3答案
// const TPManswer = Loadable({
// loader: () => import('./challengesnew/TPManswer'),
// loading: Loading,
// })
const TPManswer = Loadable({
loader: () => import('./challengesnew/TPManswer2'),
loading: Loading,
@ -138,28 +80,25 @@ const Uploadfile = Loadable({
loading: Loading,
})
const interceptorUrlArray = ['repository.json', 'commits.json', 'propaedeutics.json'
, 'challenges.json', 'discusses.json', 'ranking_list.json', 'collaborators.json']
const cacheInterceptorUrlMap = {}
class TPMIndex extends Component {
constructor(props) {
super(props)
this.state = {
loadingContent: false,
power: false,
shixunsDetails: {},
shixunId: undefined,
star_info: [0, 0, 0, 0, 0, 0],
star_infos: [0, 0, 0, 0, 0, 0],
identity:undefined,
TPMRightSectionData:undefined,
PropaedeuticsList: undefined,
tpmindexjupyterbool:false,
is_jupyter:false,
selectedKeys:"",
openknows:false,
newathArray:[]
}
constructor(props) {
super(props)
this.state = {
loadingContent: false,
power: false,
shixunsDetails: {},
shixunId: undefined,
star_info: [0, 0, 0, 0, 0, 0],
star_infos: [0, 0, 0, 0, 0, 0],
identity: undefined,
TPMRightSectionData: undefined,
PropaedeuticsList: undefined,
tpmindexjupyterbool: false,
is_jupyter: false,
selectedKeys: "",
openknows: false,
newathArray: []
}
}
@ -242,48 +181,39 @@ class TPMIndex extends Component {
public: response.data.public,
is_jupyter: response.data.is_jupyter === undefined || response.data.is_jupyter === null ? false : response.data.is_jupyter,
});
});
// this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => {
// let url = config.url;
// // console.log('tpmContentRequestInterceptor:', url)
// for ( let i = 0; i < interceptorUrlArray.length; i++ ) {
// if (url.indexOf(interceptorUrlArray[i]) != -1) {
// url = url.split('?')[0]
// console.log('loadingContent, url:', url)
//
// this.setState({ loadingContent: true })
//
// cacheInterceptorUrlMap[url] = true
// }
// }
// return config;
// }, function (error) {
// return Promise.reject(error);
// });
this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => {
let url = config.url;
// console.log('tpmContentRequestInterceptor:', url)
for (let i = 0; i < interceptorUrlArray.length; i++) {
if (url.indexOf(interceptorUrlArray[i]) != -1) {
url = url.split('?')[0]
console.log('loadingContent, url:', url)
this.setState({ loadingContent: false })
cacheInterceptorUrlMap[url] = true
if (userid) {
if (response.data.identity < 4) {
if (newTPMsettings === undefined || newTPMsettings === false || newTPMsettings === null) {
console.log()
this.setState({
openknows: true
})
} else {
this.setState({
openknows: false
})
}
}
}
}
return config;
}, function (error) {
return Promise.reject(error);
}).catch((error) => {
this.setState({
shixunsDetails: undefined,
shixunId: undefined,
star_info: undefined,
star_infos: undefined,
power: undefined,
identity: undefined,
status: undefined,
propaedeutics: undefined,
is_jupyter: false,
});
});
// Add a response interceptor
this.tpmContentResponseInterceptor = axios.interceptors.response.use((response) => {
// console.log('loadingContent finished, url:', response.config.url)
// TODO 依赖了api这个前缀
let url = response.config.url.split('api')[1];
url = url.split('?')[0]
if (cacheInterceptorUrlMap[url]) {
@ -363,13 +293,13 @@ class TPMIndex extends Component {
this.props.history.replace(`/shixuns/${id}/challenges`);
} else if (e.key === "2") {
this.props.history.replace(`/shixuns/${id}/propaedeutics`);
}else if(e.key==="3"){
} else if (e.key === "3") {
// window.location.href=`/shixuns/${id}/repository`;
this.props.history.push(`/shixuns/${id}/repository`);
}else if(e.key==="4"){
this.props.history.push(`/shixuns/${id}/repository`);
} else if (e.key === "4") {
// window.location.href=`/shixuns/${id}/secret_repository`;
this.props.history.push(`/shixuns/${id}/secret_repository`);
}else if(e.key==="5"){
} else if (e.key === "5") {
this.props.history.replace(`/shixuns/${id}/collaborators`);
} else if (e.key === "6") {
this.props.history.replace(`/shixuns/${id}/dataset`);
@ -381,29 +311,29 @@ class TPMIndex extends Component {
this.props.history.replace(`/shixuns/${id}/settings`);
}
}
setpathArray=(list)=>{
this.setState({
newathArray:list
})
setpathArray = (list) => {
this.setState({
newathArray: list
})
}
render() {
let url = window.location.href;
let flag =false;
// url.indexOf("add_file")>-1;
return (
<div className="newMain clearfix">
{/*头部*/}
{
!flag &&
<TPMBanner
{...this.props}
{...this.state}
is_jupyter={this.state. is_jupyter}
getcomponentdidmount={()=>this.getcomponentdidmount()}
></TPMBanner>
}
render() {
let url = window.location.href;
let flag = false;
// url.indexOf("add_file")>-1;
return (
<div className="newMain clearfix">
{/*头部*/}
{
!flag &&
<TPMBanner
{...this.props}
{...this.state}
is_jupyter={this.state.is_jupyter}
getcomponentdidmount={() => this.getcomponentdidmount()}
></TPMBanner>
}
<style>
@ -457,6 +387,20 @@ class TPMIndex extends Component {
{this.state.is_jupyter === false ? <Menu.Item key="8" className={"competitionmr50"}>
<span className={"tpmbannernavstyler"}>排行榜</span>
</Menu.Item> : ""}
{/*{this.state.identity >4||this.state.identity===undefined ? "":this.state.openknows===true?<span>*/}
{/* <Popover*/}
{/* content={*/}
{/* <pre className={"bannerpd201"}>*/}
{/* <div>更多设置在这里,点击“配置”看一看~</div>*/}
{/* <div className={"wechatcenter mt15"}><Button type="primary" onClick={this.openknow} >我知道了</Button></div>*/}
{/* </pre>*/}
{/* }*/}
{/* trigger="click"*/}
{/* placement="top"*/}
{/* visible={this.state.openknows}*/}
{/* >*/}
{/* </Popover>*/}
{/*</span>:""}*/}
{this.state.identity > 4 || this.state.identity === undefined ? "" :
<Menu.Item key="9" className={"competitionmr50"}>
@ -469,206 +413,184 @@ class TPMIndex extends Component {
<Link to={`/shixuns/${this.props.match.params.shixunId}/audit_situation`}
className={`${this.props.match.url.indexOf('audit_situation') != -1 ? 'font-16 audit_situationactive' : 'font-16 audit_situationactive'} fl`}>审核情况</Link>
</div>
</Row>
{/*筛选*/}
{/*{*/}
{/* tpmindexjupyterbool===false?*/}
{/* :""*/}
{/*}*/}
{/* */}
<Switch {...this.props}>
<Route path="/shixuns/:shixunId/repository/:repoId/commits" render={
(props) => (<TPMRepositoryCommits {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/:repoId/commits" render={
(props) => (<TPMRepositoryCommits {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/*任务*/}
<Route exact path="/shixuns/:shixunId/challenges" render={
(props) => (<TPMChallengeComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/upload_file" render={
(props) => (<Uploadfile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/add_file" render={
(props) => (<AddFile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/upload_file" render={
(props) => (<Uploadfile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/add_file" render={
(props) => (<AddFile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponentdetails {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponentdetails {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/* <Route exact path="/shixuns/:shixunId/propaedeutics" component={TPMPropaedeuticsComponent}></Route> */}
<Route exact path="/shixuns/:shixunId/propaedeutics" render={
(props) => (<TPMPropaedeuticsComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route exact path="/shixuns/:shixunId/collaborators" render={
(props) => (<TPMCollaboratorsComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter} setpathArray={(value)=>this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter} setpathArray={(value)=>this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter} setpathArray={(value)=>this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter} setpathArray={(value)=>this.setpathArray(value)}
/>)
}></Route>
{/* <Route exact path="/shixuns/:shixunId/propaedeutics" component={TPMPropaedeuticsComponent}></Route> */}
{/* <Route exact path="/shixuns/:shixunId/repository/:shixunId/" component={TPMRepositoryComponent}></Route> */}
<Route path="/shixuns/:shixunId/shixun_discuss" render={
(props) => (<TPMShixunDiscussContainer {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
initForumState={(data)=>this.initForumState(data)}
setSearchValue={this.setSearchValue}
setHotLabelIndex={this.setHotLabelIndex}
/>)
}></Route>
<Route path="/shixuns/:shixunId/settings" render={
(props) => (<TPMsettings {...this.props} {...this.state} {...props} getcomponentdidmount={()=>this.getcomponentdidmount()} />)
}></Route>
}
</Menu>
</Col>
</div>
</Row>
{/*实训项目条目塞选*/}
<Route exact path="/shixuns/:shixunId/ranking_list" render={
(props) => (<TPMRanking_listComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/*合作者*/}
<Route exact path="/shixuns/:shixunId/dataset" render={
(props) => (<TPMDataset {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/*筛选*/}
{/*{*/}
{/* tpmindexjupyterbool===false?*/}
<Route exact path="/shixuns/:shixunId/audit_situation" render={
(props) => (<Audit_situationComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/* :""*/}
{/*}*/}
{/* */}
<Switch {...this.props}>
<Route exact path="/shixuns/:shixunId/fork_list" render={
(props) => (<TPMFork_listComponent {...this.props} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/:repoId/commits" render={
(props) => (<TPMRepositoryCommits {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/:repoId/commits" render={
(props) => (<TPMRepositoryCommits {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/*任务*/}
<Route exact path="/shixuns/:shixunId/challenges" render={
(props) => (<TPMChallengeComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/upload_file" render={
(props) => (<Uploadfile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/add_file" render={
(props) => (<AddFile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/upload_file" render={
(props) => (<Uploadfile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/add_file" render={
(props) => (<AddFile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter} setpathArray={(value) => this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter} setpathArray={(value) => this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter} setpathArray={(value) => this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter} setpathArray={(value) => this.setpathArray(value)}
/>)
}></Route>
{/* <Route exact path="/shixuns/:shixunId/propaedeutics" component={TPMPropaedeuticsComponent}></Route> */}
<Route exact path="/shixuns/:shixunId/propaedeutics" render={
(props) => (<TPMPropaedeuticsComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route exact path="/shixuns/:shixunId/collaborators" render={
(props) => (<TPMCollaboratorsComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/* <Route exact path="/shixuns/:shixunId/repository/:shixunId/" component={TPMRepositoryComponent}></Route> */}
<Route path="/shixuns/:shixunId/shixun_discuss" render={
(props) => (<TPMShixunDiscussContainer {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
initForumState={(data) => this.initForumState(data)}
setSearchValue={this.setSearchValue}
setHotLabelIndex={this.setHotLabelIndex}
/>)
}></Route>
<Route path="/shixuns/:shixunId/settings" render={
(props) => (<TPMsettings {...this.props} {...this.state} {...props} getcomponentdidmount={() => this.getcomponentdidmount()} />)
}></Route>
{/*实训项目条目塞选*/}
<Route exact path="/shixuns/:shixunId/ranking_list" render={
(props) => (<TPMRanking_listComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/*合作者*/}
<Route exact path="/shixuns/:shixunId/dataset" render={
(props) => (<TPMDataset {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route exact path="/shixuns/:shixunId/audit_situation" render={
(props) => (<Audit_situationComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route exact path="/shixuns/:shixunId/fork_list" render={
(props) => (<TPMFork_listComponent {...this.props} {...props}
/>)
}></Route>
<Route exact path="/shixuns/:shixunId/update_propaedeutics" render={
(props) => (<TPMUpdatepropaede {...this.props} {...props}
/>)
}></Route>
<Route exact path="/shixuns/:shixunId/update_propaedeutics" render={
(props) => (<TPMUpdatepropaede {...this.props} {...props}
/>)
}></Route>
{/*评测设置*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/tab=2" render={
(props) => (<TPMevaluation {...this.props} {...props} {...this.state}/>)
}></Route>
{/*评测设置*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/tab=2" render={
(props) => (<TPMevaluation {...this.props} {...props} {...this.state} />)
}></Route>
{/*参考答案*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/tab=3" render={
(props) => (<TPManswer {...this.props} {...props} {...this.state}/>)
}></Route>
{/*参考答案*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/tab=3" render={
(props) => (<TPManswer {...this.props} {...props} {...this.state} />)
}></Route>
{/*新建关卡*/}
<Route path="/shixuns/:shixunId/challenges/new" render={
(props) => (<TPMchallengesnew {...this.props} {...props} {...this.state}/>)
}></Route>
{/*新建关卡*/}
<Route path="/shixuns/:shixunId/challenges/new" render={
(props) => (<TPMchallengesnew {...this.props} {...props} {...this.state} />)
}></Route>
{/*编辑关卡*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/editcheckpoint" render={
(props) => (<TPMchallengesnew {...this.props} {...props} {...this.state} />)
}></Route>
{/*编辑关卡*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/editcheckpoint" render={
(props) => (<TPMchallengesnew {...this.props} {...props} {...this.state} />)
}></Route>
{/*新建选择题*/}
<Route path="/shixuns/:shixunId/challenges/newquestion" render={
(props) => (<TPMquestion {...this.props} {...props} {...this.state} />)
}></Route>
{/*新建选择题*/}
<Route path="/shixuns/:shixunId/challenges/newquestion" render={
(props) => (<TPMquestion {...this.props} {...props} {...this.state} />)
}></Route>
{/*修改选择题*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/editquestion/:choose_id" render={
(props) => (<TPMquestion {...this.props} {...props} {...this.state}/>)
}></Route>
{/*修改选择题*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/editquestion/:choose_id" render={
(props) => (<TPMquestion {...this.props} {...props} {...this.state} />)
}></Route>
{/*修改选择题*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/editquestion" render={
(props) => (<TPMquestion {...this.props} {...props} {...this.state}/>)
}></Route>
{/*修改选择题*/}
<Route path="/shixuns/:shixunId/challenges/:checkpointId/editquestion" render={
(props) => (<TPMquestion {...this.props} {...props} {...this.state} />)
}></Route>
<Route exact path="/shixuns/:shixunId" render={
(props) => (<TPMChallengeComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route exact path="/shixuns/:shixunId" render={
(props) => (<TPMChallengeComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/*<Route exact path="/shixuns/:shixunId" component={TPMChallengeComponent}></Route>*/}
</Switch>
{/*<Route exact path="/shixuns/:shixunId" component={TPMChallengeComponent}></Route>*/}
</Switch>
</div>
);
}
</div>
);
}
}
export default SnackbarHOC()(TPMIndexHOC(TPMIndex));

Loading…
Cancel
Save