|
|
|
@ -163,11 +163,10 @@ class TPMIndex extends Component {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
|
|
|
|
if (prevProps != this.props) {
|
|
|
|
|
if (prevProps.user != this.props.user) {
|
|
|
|
|
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
|
|
|
|
|
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
|
|
|
|
|
if(this.state.identity <4){
|
|
|
|
|
if (prevProps!=this.props) {
|
|
|
|
|
if(this.props.user&&this.props.user.user_id){
|
|
|
|
|
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
|
|
|
|
|
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
|
|
|
|
|
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
|
|
|
|
|
this.setState({
|
|
|
|
|
openknows:true
|
|
|
|
@ -180,125 +179,123 @@ class TPMIndex extends Component {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount = () => {
|
|
|
|
|
|
|
|
|
|
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
|
|
|
|
|
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
|
// console.log('props', this.props);
|
|
|
|
|
// let collaborators = `/shixuns/` + id + `/propaedeutics.json`;
|
|
|
|
|
//
|
|
|
|
|
// axios.get(collaborators).then((response) => {
|
|
|
|
|
// if (response.status === 200) {
|
|
|
|
|
// if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
|
|
|
|
|
//
|
|
|
|
|
// }else{
|
|
|
|
|
// this.setState({
|
|
|
|
|
// PropaedeuticsList: response.data,
|
|
|
|
|
// shixunId: id
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }).catch((error) => {
|
|
|
|
|
// console.log(error)
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
let Url = `/shixuns/` + id + `.json`;
|
|
|
|
|
axios.get(Url).then((response) => {
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
document.title=response.data.name;
|
|
|
|
|
let newstar_info = [];
|
|
|
|
|
// let start1=
|
|
|
|
|
for (var i = 0; i < response.data.score_info.length; i++) {
|
|
|
|
|
|
|
|
|
|
if (i === 0) {
|
|
|
|
|
newstar_info.push(response.data.score_info[i])
|
|
|
|
|
} else {
|
|
|
|
|
newstar_info.push((response.data.score_info[i] / 100) * 5)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let newstar_infos = response.data.score_info;
|
|
|
|
|
getcomponentdidmount=()=>{
|
|
|
|
|
let userid=this.props.user&&this.props.user.user_id;
|
|
|
|
|
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
|
|
|
|
|
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
|
// console.log('props', this.props);
|
|
|
|
|
// let collaborators = `/shixuns/` + id + `/propaedeutics.json`;
|
|
|
|
|
//
|
|
|
|
|
// axios.get(collaborators).then((response) => {
|
|
|
|
|
// if (response.status === 200) {
|
|
|
|
|
// if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
|
|
|
|
|
//
|
|
|
|
|
// }else{
|
|
|
|
|
// this.setState({
|
|
|
|
|
// PropaedeuticsList: response.data,
|
|
|
|
|
// shixunId: id
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }).catch((error) => {
|
|
|
|
|
// console.log(error)
|
|
|
|
|
// });
|
|
|
|
|
let Url = `/shixuns/` + id + `.json`;
|
|
|
|
|
axios.get(Url).then((response) => {
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
document.title=response.data.name;
|
|
|
|
|
let newstar_info = [];
|
|
|
|
|
// let start1=
|
|
|
|
|
for (var i = 0; i < response.data.score_info.length; i++) {
|
|
|
|
|
|
|
|
|
|
if (i === 0) {
|
|
|
|
|
newstar_info.push(response.data.score_info[i])
|
|
|
|
|
} else {
|
|
|
|
|
newstar_info.push((response.data.score_info[i] / 100) * 5)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let newstar_infos = response.data.score_info;
|
|
|
|
|
this.setState({
|
|
|
|
|
shixunsDetails: response.data,
|
|
|
|
|
shixunId: id,
|
|
|
|
|
star_info: newstar_info,
|
|
|
|
|
star_infos: newstar_infos,
|
|
|
|
|
power: response.data.power,
|
|
|
|
|
identity: response.data.identity,
|
|
|
|
|
propaedeutics:response.data.propaedeutics,
|
|
|
|
|
status: response.data.shixun_status,
|
|
|
|
|
secret_repository: response.data.secret_repository,
|
|
|
|
|
public:response.data.public,
|
|
|
|
|
is_jupyter:response.data.is_jupyter=== undefined||response.data.is_jupyter===null?false:response.data.is_jupyter,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if(userid){
|
|
|
|
|
if(response.data.identity <4){
|
|
|
|
|
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
|
|
|
|
|
console.log()
|
|
|
|
|
this.setState({
|
|
|
|
|
shixunsDetails: response.data,
|
|
|
|
|
shixunId: id,
|
|
|
|
|
star_info: newstar_info,
|
|
|
|
|
star_infos: newstar_infos,
|
|
|
|
|
power: response.data.power,
|
|
|
|
|
identity: response.data.identity,
|
|
|
|
|
propaedeutics:response.data.propaedeutics,
|
|
|
|
|
status: response.data.shixun_status,
|
|
|
|
|
secret_repository: response.data.secret_repository,
|
|
|
|
|
public:response.data.public,
|
|
|
|
|
is_jupyter:response.data.is_jupyter=== undefined||response.data.is_jupyter===null?false:response.data.is_jupyter,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(response.data.identity <4){
|
|
|
|
|
|
|
|
|
|
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
|
|
|
|
|
this.setState({
|
|
|
|
|
openknows:true
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
openknows:false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
openknows:true
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
openknows:false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}).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,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}).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];
|
|
|
|
|
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]
|
|
|
|
|
if (cacheInterceptorUrlMap[url]) {
|
|
|
|
|
console.log('loadingContent, url:', url)
|
|
|
|
|
|
|
|
|
|
this.setState({ loadingContent: false })
|
|
|
|
|
delete cacheInterceptorUrlMap[response.url]
|
|
|
|
|
}
|
|
|
|
|
return response;
|
|
|
|
|
}, function (error) {
|
|
|
|
|
// Do something with response error
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|
});
|
|
|
|
|
this.setState({ loadingContent: true })
|
|
|
|
|
|
|
|
|
|
cacheInterceptorUrlMap[url] = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return config;
|
|
|
|
|
}, function (error) {
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 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]) {
|
|
|
|
|
|
|
|
|
|
this.setState({ loadingContent: false })
|
|
|
|
|
delete cacheInterceptorUrlMap[response.url]
|
|
|
|
|
}
|
|
|
|
|
return response;
|
|
|
|
|
}, function (error) {
|
|
|
|
|
// Do something with response error
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|
});
|
|
|
|
|
//右侧数据
|
|
|
|
|
let shixunsDetailsURL=`/shixuns/`+id+`/show_right.json`;
|
|
|
|
|
axios.get(shixunsDetailsURL).then((response)=> {
|
|
|
|
@ -311,6 +308,10 @@ class TPMIndex extends Component {
|
|
|
|
|
})
|
|
|
|
|
this.getnavdatas()
|
|
|
|
|
}
|
|
|
|
|
componentDidMount = () => {
|
|
|
|
|
this.getcomponentdidmount()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount = () => {
|
|
|
|
|
axios.interceptors.request.eject(this.tpmContentRequestInterceptor);
|
|
|
|
@ -383,6 +384,7 @@ class TPMIndex extends Component {
|
|
|
|
|
let url = window.location.href;
|
|
|
|
|
let flag = url.indexOf("add_file")>-1;
|
|
|
|
|
|
|
|
|
|
console.log(this.state.openknows)
|
|
|
|
|
return (
|
|
|
|
|
<div className="newMain clearfix">
|
|
|
|
|
{/*头部*/}
|
|
|
|
@ -447,7 +449,7 @@ class TPMIndex extends Component {
|
|
|
|
|
{ this.state.is_jupyter===false? <Menu.Item key="8" className={"competitionmr50"}>
|
|
|
|
|
<span className={"tpmbannernavstyler"}>排行榜</span>
|
|
|
|
|
</Menu.Item>:""}
|
|
|
|
|
<span>
|
|
|
|
|
{this.state.identity >4||this.state.identity===undefined ? "":this.state.openknows===true?<span>
|
|
|
|
|
<Popover
|
|
|
|
|
content={
|
|
|
|
|
<pre className={"bannerpd201"}>
|
|
|
|
@ -460,7 +462,7 @@ class TPMIndex extends Component {
|
|
|
|
|
visible={this.state.openknows}
|
|
|
|
|
>
|
|
|
|
|
</Popover>
|
|
|
|
|
</span>
|
|
|
|
|
</span>:""}
|
|
|
|
|
|
|
|
|
|
{this.state.identity >4||this.state.identity===undefined ? "":
|
|
|
|
|
<Menu.Item key="9" className={"competitionmr50"}>
|
|
|
|
|