This commit is contained in:
caishi 2020-08-09 23:08:11 +08:00
parent 1a024f8011
commit 5601b71937
1 changed files with 33 additions and 35 deletions

View File

@ -50,7 +50,8 @@ class NewHeader extends Component {
}
}
componentDidMount() {
this.getAppdata();
// this.getAppdata();
this.geturlsdata();
window._header_componentHandler = this;
//下拉框的显示隐藏
@ -547,13 +548,12 @@ class NewHeader extends Component {
geturlsdata = () => {
let url = "/setting.json";
axios.get(url).then((response) => {
if (response) {
if (response.data) {
if (response && response.data) {
this.setState({
mygetHelmetapi2: response.data.setting
});
localStorage.setItem('chromesetting', JSON.stringify(response.data.setting));
localStorage.setItem('chromesettingresponse', JSON.stringify(response));
// localStorage.setItem('chromesetting', JSON.stringify(response.data.setting));
// localStorage.setItem('chromesettingresponse', JSON.stringify(response));
try {
if (response.data.setting.tab_logo_url) {
this.gettablogourldata(response);
@ -566,18 +566,15 @@ class NewHeader extends Component {
} else {
this.gettablogourlnull();
}
} else {
this.gettablogourlnull();
}
}).catch((error) => {
this.gettablogourlnull();
});
}
matchpaths = (url) => {
const { match } = this.props;
if(url){
if (url === '/forums' && match.path === '/forums') {
return true
} else if (url.startsWith('/projects') && match.path.startsWith('/projects')) {
@ -596,6 +593,7 @@ class NewHeader extends Component {
return false
}
}
}
// 处理弹框
@ -741,7 +739,7 @@ class NewHeader extends Component {
var new_link = item.link;
var user_login = this.props.user && this.props.user.login;
var is_hidden = item.hidden
if (new_link.indexOf("courses") > -1 || new_link.indexOf("contests") > -1) {
if (new_link && (new_link.indexOf("courses") > -1 || new_link.indexOf("contests") > -1)) {
if (user_login) {
if (new_link.indexOf("courses") > -1) {
new_link = new_link.replace(/courses/g, "users/" + user_login + "/courses")
@ -752,7 +750,7 @@ class NewHeader extends Component {
is_hidden = true
}
}
if (user_login && new_link.indexOf("homes") > -1) {
if (user_login && (new_link && new_link.indexOf("homes") > -1)) {
new_link = new_link.replace(/homes/g, "users/" + user_login + "/user_activities")
}
return (