forked from Gitlink/forgeplus-react
913 lines
28 KiB
JavaScript
913 lines
28 KiB
JavaScript
import React, { Component } from 'react';
|
|
import { Link } from "react-router-dom";
|
|
import AccountProfile from "../user/AccountProfile";
|
|
import { getImageUrl,getLogoImageUrl } from 'educoder';
|
|
import { getUserInfo } from 'src/military/expert/api';
|
|
import axios from 'axios';
|
|
import { Modal, Input, message, notification, Button, Popover, Badge } from 'antd';
|
|
|
|
import LoginDialog from '../login/LoginDialog';
|
|
import GotoQQgroup from '../../modal/GotoQQgroup'
|
|
import 'antd/lib/modal/style/index.css';
|
|
import 'antd/lib/checkbox/style/index.css';
|
|
import 'antd/lib/radio/style/index.css';
|
|
import 'antd/lib/input/style/index.css';
|
|
import './TPMIndex.css';
|
|
import './css/headerExcess.css';
|
|
import logo from './images/hskylogo.png';
|
|
import AddProjectModal from '../../forge/Head/AddProjectModal';
|
|
import NoticeContent from 'src/forge/Head/NoticeContent';
|
|
|
|
const $ = window.$
|
|
// TODO 这部分脚本从公共脚本中直接调用
|
|
const { Search } = Input;
|
|
let old_url;
|
|
|
|
window._header_componentHandler = null;
|
|
// 非trustie链接则新开页跳转
|
|
const str = ['www.trustie.net','forgeplus.trustie.net','forum.trustie.net','testforgeplus.trustie.net']
|
|
class NewHeader extends Component {
|
|
constructor(props) {
|
|
super(props)
|
|
this.state = {
|
|
Addcoursestypes: false,
|
|
tojoinitemtype: false,
|
|
tojoinclasstitle: undefined,
|
|
rolearr: ["", ""],
|
|
Checkboxteacherchecked: false,
|
|
Checkboxstudentchecked: false,
|
|
Checkboxteachingchecked: false,
|
|
Checkboxteachertype: false,
|
|
Checkboxteachingtype: false,
|
|
code_notice: false,
|
|
checked_notice: false,
|
|
RadioGroupvalue: undefined,
|
|
submitapplications: false,
|
|
isRender: false,
|
|
showSearchOpentype: false,
|
|
showTrial: false,
|
|
setevaluatinghides: false,
|
|
occupation: 0,
|
|
mydisplay: false,
|
|
headtypesonClickbool: false,
|
|
headtypess: "/",
|
|
settings: null,
|
|
goshowqqgtounp: false,
|
|
visiblemyss: false,
|
|
visible:false, //浮动消息框展示控制
|
|
}
|
|
}
|
|
componentDidMount() {
|
|
// this.getAppdata();
|
|
this.geturlsdata();
|
|
window._header_componentHandler = this;
|
|
|
|
//下拉框的显示隐藏
|
|
var hoverTimeout;
|
|
var hoveredPanel;
|
|
$(".edu-menu-panel").hover(function () {
|
|
if (hoverTimeout) { // 一次只显示一个panel
|
|
if (hoveredPanel && hoveredPanel !== this) {
|
|
$(hoveredPanel).find(".edu-menu-list").hide()
|
|
}
|
|
clearTimeout(hoverTimeout);
|
|
hoverTimeout = null;
|
|
}
|
|
hoveredPanel = this;
|
|
$(this).find(".edu-menu-list").show();
|
|
}, function () {
|
|
var that = this;
|
|
// 延迟hide
|
|
hoverTimeout = setTimeout(function () {
|
|
$(that).find(".edu-menu-list").hide();
|
|
}, 800)
|
|
|
|
});
|
|
//获取游览器地址
|
|
try {
|
|
window.sessionStorage.setItem("yslgeturls", JSON.stringify(window.location.href))
|
|
} catch (e) {}
|
|
}
|
|
|
|
openNotification = (messge) => {
|
|
notification.open({
|
|
message: "提示",
|
|
description:
|
|
messge,
|
|
});
|
|
};
|
|
|
|
componentWillReceiveProps(newProps, oldProps) {
|
|
this.setState({
|
|
user: newProps.user
|
|
})
|
|
if (newProps.Headertop !== undefined) {
|
|
old_url = newProps.Headertop.old_url
|
|
}
|
|
|
|
}
|
|
getCookie = (key) => {
|
|
var arr, reg = RegExp('(^| )' + key + '=([^;]+)(;|$)');
|
|
if (arr === document.cookie.match(reg))
|
|
return decodeURIComponent(arr[2]);
|
|
else
|
|
return null;
|
|
}
|
|
|
|
delCookie = (name) => {
|
|
var exp = new Date();
|
|
exp.setTime(exp.getTime() - 1);
|
|
var cval = this.getCookie(name);
|
|
if (cval != null) {
|
|
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
|
|
}
|
|
}
|
|
onLogout = () => {
|
|
const url = `/accounts/logout.json`
|
|
this.delCookie("autologin_trustie")
|
|
axios.get(url, {
|
|
}).then((response) => {
|
|
if (response.data.status === 1) {
|
|
this.setState({
|
|
user: undefined
|
|
})
|
|
window.location.href = "/login"
|
|
message.success('退出成功');
|
|
}
|
|
});
|
|
}
|
|
|
|
tojoinclass = () => {
|
|
let { user } = this.state;
|
|
if (user === undefined) {
|
|
this.setState({
|
|
isRender: true
|
|
})
|
|
return
|
|
}
|
|
if (user && user.login === "") {
|
|
this.setState({
|
|
isRender: true
|
|
})
|
|
return;
|
|
}
|
|
if (user && user.profile_completed === false) {
|
|
this.setState({
|
|
AccountProfiletype: true
|
|
})
|
|
return;
|
|
}
|
|
this.setState({
|
|
Addcoursestypes: true,
|
|
})
|
|
}
|
|
|
|
tojoinitem = () => {
|
|
if (this.props.user && this.props.user.email === undefined || this.props.user && this.props.user.email === null || this.props.user && this.props.user.email === "") {
|
|
this.openNotification("请先绑定邮箱,谢谢");
|
|
return
|
|
}
|
|
let { user } = this.state;
|
|
if (user === undefined) {
|
|
this.setState({
|
|
isRender: true
|
|
})
|
|
return
|
|
}
|
|
if (user && user.login === "") {
|
|
this.setState({
|
|
isRender: true
|
|
})
|
|
return;
|
|
}
|
|
|
|
if (user && user.profile_completed === false) {
|
|
this.setState({
|
|
AccountProfiletype: true
|
|
})
|
|
return;
|
|
}
|
|
|
|
this.setState({
|
|
tojoinitemtype: true
|
|
})
|
|
}
|
|
|
|
|
|
submitstatevalue = (sum, value, data) => {
|
|
this.setState({
|
|
Addcoursestypes: false,
|
|
tojoinitemtype: false,
|
|
tojoinclasstitle: undefined,
|
|
rolearr: ["", ""],
|
|
Checkboxteacherchecked: false,
|
|
Checkboxstudentchecked: false,
|
|
Checkboxteachingchecked: false,
|
|
Checkboxteachertype: false,
|
|
Checkboxteachingtype: false,
|
|
code_notice: false,
|
|
checked_notice: false,
|
|
submitapplicationssum: sum,
|
|
submitapplications: true,
|
|
submitapplicationsvalue: value,
|
|
submitapplicationsvaluedata: data,
|
|
RadioGroupvalue: undefined
|
|
})
|
|
}
|
|
|
|
onChangeRadioGroup = (e) => {
|
|
this.setState({
|
|
RadioGroupvalue: e.target.value,
|
|
});
|
|
}
|
|
|
|
submitsubmitapplications = () => {
|
|
let {
|
|
submitapplicationssum,
|
|
submitapplicationsvaluedata
|
|
} = this.state;
|
|
this.setState({
|
|
submitapplications: false,
|
|
RadioGroupvalue: undefined
|
|
})
|
|
if (submitapplicationssum === 0) {
|
|
if (submitapplicationsvaluedata !== undefined) {
|
|
window.location.href = "/courses/" + submitapplicationsvaluedata;
|
|
}
|
|
} else if (submitapplicationssum === 1) {
|
|
if (submitapplicationsvaluedata !== undefined) {
|
|
window.location.href = "/projects/" + submitapplicationsvaluedata;
|
|
}
|
|
}
|
|
}
|
|
|
|
hidesubmitapplications = () => {
|
|
this.setState({
|
|
Addcoursestypes: false,
|
|
tojoinitemtype: false,
|
|
tojoinclasstitle: undefined,
|
|
rolearr: ["", ""],
|
|
Checkboxteacherchecked: false,
|
|
Checkboxstudentchecked: false,
|
|
Checkboxteachingchecked: false,
|
|
Checkboxteachertype: false,
|
|
Checkboxteachingtype: false,
|
|
code_notice: false,
|
|
checked_notice: false,
|
|
submitapplications: false,
|
|
RadioGroupvalue: undefined
|
|
})
|
|
}
|
|
educoderlogin = () => {
|
|
//登录账号
|
|
this.setState({
|
|
isRender: true
|
|
})
|
|
}
|
|
educoderloginysl = () => {
|
|
//退出账号
|
|
var url = `/accounts/logout.json`;
|
|
axios.get((url)).then((result) => {
|
|
if (result !== undefined) {
|
|
window.location.href = "/";
|
|
}
|
|
}).catch((error) => {
|
|
console.log(error);
|
|
})
|
|
}
|
|
|
|
hideAddcoursestypes = () => {
|
|
this.setState({
|
|
Addcoursestypes: false
|
|
})
|
|
};
|
|
HideAddcoursestypess = (i) => {
|
|
this.setState({
|
|
Addcoursestypes: false,
|
|
mydisplay: true,
|
|
occupation: i,
|
|
})
|
|
};
|
|
ModalCancelsy = () => {
|
|
this.setState({
|
|
mydisplay: false,
|
|
})
|
|
};
|
|
|
|
|
|
hidetojoinclass = () => {
|
|
this.setState({
|
|
tojoinclasstype: false,
|
|
tojoinitemtype: false,
|
|
tojoinclasstitle: undefined,
|
|
rolearr: ["", ""],
|
|
Checkboxteacherchecked: false,
|
|
Checkboxstudentchecked: false,
|
|
Checkboxteachingchecked: false,
|
|
Checkboxteachertype: false,
|
|
Checkboxteachingtype: false,
|
|
code_notice: false,
|
|
checked_notice: false,
|
|
RadioGroupvalue: undefined
|
|
})
|
|
}
|
|
|
|
submittojoinclass = (value) => {
|
|
let { tojoinclasstitle, rolearr, RadioGroupvalue } = this.state;
|
|
|
|
if (tojoinclasstitle === undefined) {
|
|
this.setState({
|
|
code_notice: true
|
|
})
|
|
return
|
|
}
|
|
let newrolearr = rolearr;
|
|
if (tojoinclasstitle.length < 6) {
|
|
this.setState({
|
|
code_notice: true
|
|
})
|
|
return
|
|
}
|
|
if (tojoinclasstitle === "" || tojoinclasstitle === undefined) {
|
|
this.setState({
|
|
code_notice: true
|
|
})
|
|
return
|
|
} else {
|
|
this.setState({
|
|
code_notice: false
|
|
})
|
|
}
|
|
|
|
let pamst = [];
|
|
let num = 0;
|
|
for (var i = 0; i < newrolearr.length; i++) {
|
|
if (newrolearr[i] !== "") {
|
|
pamst.push(newrolearr[i])
|
|
} else {
|
|
num = num + 1
|
|
}
|
|
}
|
|
|
|
if (num === 2 && value === 0) {
|
|
this.setState({
|
|
checked_notice: true
|
|
})
|
|
return
|
|
}
|
|
|
|
if (value === 1 && RadioGroupvalue === undefined) {
|
|
this.setState({
|
|
checked_notice: true
|
|
})
|
|
return
|
|
}
|
|
if (value === 1) {
|
|
let url = "/project_applies.json";
|
|
axios.post(url, {
|
|
code: tojoinclasstitle,
|
|
role: RadioGroupvalue
|
|
}
|
|
).then((response) => {
|
|
if (response.data.status === 1) {
|
|
this.submitstatevalue(1, "您输入的邀请码错误")
|
|
} else if (response.data.status === 2) {
|
|
this.submitstatevalue(1, "您已经是该项目成员", response.data.project)
|
|
} else if (response.data.status === 3) {
|
|
this.submitstatevalue(1, "请选择一个角色")
|
|
} else if (response.data.status === 4) {
|
|
this.submitstatevalue(1, "您的申请已提交,请等待项目管理员审批")
|
|
} else if (response.data.status === 5) {
|
|
this.submitstatevalue(1, "您已经申请加入该项目了,请耐心等待")
|
|
} else if (response.data.status === 6) {
|
|
this.submitstatevalue(1, "您已成功加入项目", response.data.project)
|
|
} else if (response.data.status === 0) {
|
|
if (RadioGroupvalue === "reporter") {
|
|
this.openNotification("您加入项目成功!");
|
|
window.location.href = `/projects/${response.data.project_id}`;
|
|
} else {
|
|
this.openNotification("您的申请已提交,请等待项目管理员审批!");
|
|
}
|
|
}
|
|
})
|
|
}
|
|
this.hidetojoinclass()
|
|
}
|
|
// 关闭
|
|
cancelModulationModels = () => {
|
|
this.setState({ isRenders: false })
|
|
}
|
|
|
|
inputjoinclassvalue = (e) => {
|
|
if (e.target.value.length >= 7) {
|
|
this.openNotification("请输入6位项目邀请码!");
|
|
return
|
|
}
|
|
this.setState({
|
|
tojoinclasstitle: e.target.value
|
|
})
|
|
}
|
|
|
|
showSearchOpen = (e) => {
|
|
this.setState({
|
|
showSearchOpentype: true
|
|
})
|
|
}
|
|
|
|
hideshowSearchOpen = (e) => {
|
|
let { setevaluatinghides } = this.state;
|
|
if (setevaluatinghides === true) {
|
|
this.setState({
|
|
showSearchOpentype: false,
|
|
setevaluatinghides: false
|
|
})
|
|
}
|
|
}
|
|
|
|
onKeywordSearchKeyDown = (value) => {
|
|
let url = `/search?value=${value}`;
|
|
this.props.history.push(url)
|
|
}
|
|
|
|
onKeywordSearchKeyDowns = () => {
|
|
this.setState({
|
|
setevaluatinghides: false
|
|
})
|
|
}
|
|
|
|
setevaluatinghides = () => {
|
|
this.setState({
|
|
setevaluatinghides: true
|
|
})
|
|
}
|
|
//头部获取是否已经登录了
|
|
getUser = (url, type) => {
|
|
if (type === "projects") {
|
|
if (this.props.user && this.props.user.email === undefined || this.props.user && this.props.user.email === null || this.props.user && this.props.user.email === "") {
|
|
this.openNotification("请先绑定邮箱,谢谢");
|
|
return
|
|
}
|
|
}
|
|
let { user } = this.state;
|
|
|
|
if (user === undefined) {
|
|
this.setState({
|
|
isRender: true
|
|
})
|
|
return
|
|
}
|
|
if (user && user.login === "") {
|
|
this.setState({
|
|
isRender: true
|
|
})
|
|
return;
|
|
}
|
|
|
|
if (user && user.profile_completed === false) {
|
|
this.setState({
|
|
AccountProfiletype: true
|
|
})
|
|
return;
|
|
}
|
|
if (type === "newshixuns") {
|
|
if (this.props && this.props.current_user && this.props.current_user.is_shixun_marker === false) {
|
|
this.setgoshowqqgtounp(true);
|
|
return;
|
|
}
|
|
}
|
|
if (url !== undefined || url !== "") {
|
|
window.location.href = url;
|
|
}
|
|
}
|
|
|
|
//修改登录方法
|
|
Modifyloginvalue = () => {
|
|
this.setState({
|
|
isRender: false,
|
|
})
|
|
}
|
|
|
|
hideAccountProfile = () => {
|
|
this.setState({
|
|
AccountProfiletype: false
|
|
})
|
|
};
|
|
headtypesonClick = (url, bool) => {
|
|
this.setState({
|
|
headtypess: url,
|
|
headtypesonClickbool: bool,
|
|
})
|
|
}
|
|
//获取数据为空的时候
|
|
gettablogourlnull = () => {
|
|
this.setState({
|
|
settings: undefined
|
|
});
|
|
var link = document.createElement('link'),
|
|
oldLink = document.getElementById('dynamic-favicon');
|
|
link.id = 'dynamic-favicon';
|
|
link.rel = 'shortcut icon';
|
|
link.href = "/react/build/./favicon.ico";
|
|
if (oldLink) {
|
|
document.head.removeChild(oldLink);
|
|
}
|
|
document.head.appendChild(link);
|
|
};
|
|
|
|
//获取数据的时候
|
|
gettablogourldata = (response) => {
|
|
document.title = response.data.setting.name;
|
|
var link = document.createElement('link'),
|
|
oldLink = document.getElementById('dynamic-favicon');
|
|
link.id = 'dynamic-favicon';
|
|
link.rel = 'shortcut icon';
|
|
link.href = '/' + response.data.setting.tab_logo_url;
|
|
if (oldLink) {
|
|
document.head.removeChild(oldLink);
|
|
}
|
|
document.head.appendChild(link);
|
|
}
|
|
|
|
handleVisibleChanges = (boll) => {
|
|
this.setState({
|
|
visiblemyss: boll,
|
|
})
|
|
}
|
|
|
|
getAppdata = () => {
|
|
try {
|
|
var chromesettingArray = JSON.parse(localStorage.getItem('chromesetting'));
|
|
var chromesettingresponseArray = JSON.parse(localStorage.getItem('chromesettingresponse'));
|
|
this.setState({
|
|
settings: chromesettingArray
|
|
});
|
|
if (chromesettingArray.tab_logo_url) {
|
|
this.gettablogourldata(chromesettingresponseArray);
|
|
} else {
|
|
this.gettablogourlnull();
|
|
}
|
|
} catch (e) {
|
|
this.geturlsdata();
|
|
}
|
|
};
|
|
|
|
geturlsdata = () => {
|
|
let url = "/setting.json";
|
|
axios.get(url).then((response) => {
|
|
if (response && response.data) {
|
|
this.setState({ settings: response.data.setting });
|
|
// 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);
|
|
} else {
|
|
this.gettablogourlnull();
|
|
}
|
|
} catch (e) {
|
|
this.gettablogourlnull();
|
|
}
|
|
} else {
|
|
this.gettablogourlnull();
|
|
}
|
|
}).catch((error) => {
|
|
this.gettablogourlnull();
|
|
});
|
|
}
|
|
|
|
matchpaths = (url) => {
|
|
const { match } = this.props;
|
|
const hostname = window.location.hostname;
|
|
const port = window.location.port;
|
|
const isDev = hostname == "localhost";
|
|
let isdev2= isDev ?'http://117.50.100.12:49999':`http://${hostname}`;
|
|
let str = "";
|
|
if(url.indexOf("http")>-1){
|
|
if(url.indexOf("https")>-1){
|
|
isdev2 = `https://${hostname}`;
|
|
}
|
|
if(!isDev && port){
|
|
isdev2+=`:${port}`;
|
|
}
|
|
str = isdev2+match.path;
|
|
}else{
|
|
str = match.path;
|
|
}
|
|
|
|
console.log(str,(url+"/"),url && str === url);
|
|
if (url && (str === url || str===(url+"/"))) {
|
|
return true
|
|
}else {
|
|
return false
|
|
}
|
|
|
|
// const { match } = this.props;
|
|
// let pathname=sessionStorage.pathname;
|
|
// console.log(url);
|
|
// if(url){
|
|
// if (url.indexOf('forums') > -1 && match.path.indexOf('forums') > -1) {
|
|
// return true
|
|
// // 开源项目,路由改版后,比较麻烦,因此使用多个进行判断
|
|
// } else if (url.indexOf('explore') > -1 && match.path.indexOf('explore') > -1) {
|
|
// return true
|
|
// // 开源项目,路由改版后,比较麻烦,因此使用多个进行判断
|
|
// } else if (url.indexOf('explore') > -1 && match.url.indexOf(pathname) > -1 && match.url.indexOf('/administration') === -1 && match.url.indexOf('/admin') === -1) {
|
|
// return true
|
|
// // 公告
|
|
// } else if (url.indexOf('/notice') > -1 && match.path.indexOf('/notice') > -1) {
|
|
// return true
|
|
// // 创客
|
|
// } else if (url.indexOf('/task') > -1 && match.path.indexOf('/task') > -1) {
|
|
// return true
|
|
// // 成果库
|
|
// } else if (url.indexOf('/achievement') > -1 && match.path.indexOf('/achievement') > -1) {
|
|
// return true
|
|
// // 管理
|
|
// } else if ((url.indexOf('/managements') > -1 && (match.path.indexOf('/managements') > -1 || match.path.indexOf('/administration') > -1 || match.path.indexOf('/admin') > -1))) {
|
|
// return true
|
|
// } else if (['http://117.50.100.12:8080','https://osredm.com','http://111.8.36.180:8000','http://localhost:3007'].includes(url) && match.path === '/') {
|
|
// return true
|
|
// } else {
|
|
// return false
|
|
// }
|
|
// }
|
|
}
|
|
|
|
handleVisibleChange = visible => {
|
|
this.setState({ visible });
|
|
};
|
|
|
|
// 处理弹框
|
|
setgoshowqqgtounp = (bool) => {
|
|
this.setState({
|
|
goshowqqgtounp: bool
|
|
})
|
|
}
|
|
needAdd=(url)=> {
|
|
let {current_user,mygetHelmetapi,history}=this.props;
|
|
if (current_user.authentication || current_user.enterprise_certification) {
|
|
history.push('/needs/new')
|
|
} else {
|
|
Modal.confirm({
|
|
content: "请先完成实名认证再提交需求申请,是否前往认证?",
|
|
onOk() {
|
|
window.location.href=`${mygetHelmetapi && mygetHelmetapi.main_web_site_url}/users/${current_user.login}/profiles`;
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { resetUserInfo , showNotification, match, current_user } = this.props;
|
|
|
|
let { Addcoursestypes,
|
|
tojoinitemtype,
|
|
tojoinclasstitle,
|
|
code_notice,
|
|
checked_notice,
|
|
AccountProfiletype,
|
|
submitapplications,
|
|
submitapplicationsvalue,
|
|
user,
|
|
isRender,
|
|
showSearchOpentype,
|
|
headtypesonClickbool,
|
|
headtypess,
|
|
settings,
|
|
goshowqqgtounp,
|
|
visible,
|
|
} = this.state;
|
|
let activeIndex =match.path === '/' || (match.path&&match.path.startsWith('/managements')) || (match.path&&match.path.startsWith('/admin'))?true: '';
|
|
let headtypes = '/';
|
|
if (settings) {
|
|
if (settings.navbar) {
|
|
if (settings.navbar.length > 0) {
|
|
if (match.path === '/') {
|
|
if (headtypesonClickbool === false) {
|
|
headtypes = undefined;
|
|
} else {
|
|
headtypes = headtypess;
|
|
}
|
|
} else {
|
|
for (var i = 0; i < settings.navbar.length; i++) {
|
|
if (match.path === settings.navbar[i].link) {
|
|
headtypes = settings.navbar[i].link;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let shixuntype = false;
|
|
let pathstype = false;
|
|
let coursestypes = false;
|
|
if (this.props && this.props.mygetHelmetapi != null) {
|
|
// let shixun = "/shixuns";
|
|
// let paths = "/paths";
|
|
let courses = "/courses";
|
|
this.props.mygetHelmetapi.navbar.map((item, key) => {
|
|
var reg = RegExp(item.link);
|
|
// if (shixun.match(reg)) {
|
|
// if (item.hidden === true) {
|
|
// shixuntype = true
|
|
// }
|
|
// }
|
|
// if (paths.match(reg)) {
|
|
// if (item.hidden === true) {
|
|
// pathstype = true
|
|
// }
|
|
// }
|
|
if (courses.match(reg)) {
|
|
if (item.hidden === true) {
|
|
coursestypes = true
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
return (
|
|
<div className={`newHeaders ${activeIndex && 'homePage'}`} id="nHeader">
|
|
<div className="headerContent">
|
|
{isRender === true ?
|
|
<LoginDialog
|
|
{...this.props}
|
|
{...this.state}
|
|
Modifyloginvalue={() => this.Modifyloginvalue()}
|
|
/> : ""}
|
|
|
|
{AccountProfiletype === true ?
|
|
<AccountProfile
|
|
hideAccountProfile={() => this.hideAccountProfile()}
|
|
{...this.props}
|
|
{...this.state}
|
|
/> : ""}
|
|
{
|
|
goshowqqgtounp === true ?
|
|
<GotoQQgroup {...this.state} {...this.props} setgoshowqqgtounp={(bool) => this.setgoshowqqgtounp(bool)}></GotoQQgroup>
|
|
:""
|
|
}
|
|
<a href={settings && settings.new_course.default_url} className={"fl mr30"} style={{minWidth:"45px"}}>
|
|
{
|
|
settings && settings.nav_logo_url ?
|
|
<img alt="红山开源社区" className="logoimg" style={{ heigth: "40px" }} src={activeIndex?logo:getLogoImageUrl(settings.nav_logo_url)}></img>
|
|
:
|
|
""
|
|
}
|
|
</a>
|
|
<div className="head-nav pr" id={"head-navpre1"}>
|
|
{
|
|
settings && settings.navbar && settings.navbar.length > 0 ?
|
|
<ul id="header-nav">
|
|
{
|
|
settings.navbar && settings.navbar.map((item, key) => {
|
|
var new_link = item.link;
|
|
var user_login = this.props.user && this.props.user.login;
|
|
var is_hidden = item.hidden
|
|
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, user_login + "/courses")
|
|
} else if (new_link.indexOf("contests") > -1) {
|
|
new_link = new_link.replace(/contests/g, user_login + "/contests")
|
|
}
|
|
} else {
|
|
is_hidden = true
|
|
}
|
|
}
|
|
if (user_login && (new_link && new_link.indexOf("homes") > -1)) {
|
|
new_link = new_link.replace(/homes/g, user_login + "/user_activities")
|
|
}
|
|
|
|
var waiLian = (new_link && str.filter(item=>new_link.indexOf(item)>-1) );
|
|
var wl = waiLian && waiLian.length>0;
|
|
return (
|
|
<li key={key} onClick={() => this.headtypesonClick(item.link, true)} className={`${this.matchpaths(item.link) === true ? 'pr active' : 'pr'}`} style={!is_hidden ? { display: 'flex' } : { display: 'none' }}>
|
|
<a href={new_link}>{item.name}</a>
|
|
</li>
|
|
)
|
|
})
|
|
}
|
|
</ul>
|
|
: ""
|
|
}
|
|
</div>
|
|
<div className="head-right">
|
|
{this.props.user && this.props.user.login &&
|
|
<div className='mr30'>
|
|
<a href={current_user.isExpert ? '/expert/user/tasks' : current_user.expertDraft ? '/expert/user/register' : '/expert'}>
|
|
<i className={`iconfont icon-ioon ${activeIndex?'color-home':'color-grey-9'} font-22`}></i>
|
|
</a>
|
|
</div>
|
|
}
|
|
{this.props.user && this.props.user.login &&
|
|
<div className="edu-menu-panel mr5">
|
|
<i className={`iconfont icon-tianjiafangda ${activeIndex?'color-home':'color-grey-6'} `}></i>
|
|
<div className="edu-menu-list" style={{ top: '48px' }}>
|
|
<div className="overPart"></div>
|
|
{
|
|
(coursestypes === true && this.props.user.main_site === false && (settings && !settings.add && (settings.add && settings.add.length === 0))) ? "" :
|
|
<ul className="edu-txt-center">
|
|
{
|
|
settings && settings.add && settings.add.map((item,key)=>{
|
|
return(
|
|
<li key={key}>
|
|
{ item.url.indexOf('needs/new')<0?<a href={item.url}>{item.name}</a>:<a onClick={()=>{this.needAdd(item.url)}}>{item.name}</a>}
|
|
</li>
|
|
)
|
|
})
|
|
}
|
|
<li>
|
|
<AddProjectModal {...this.props} showNotification={this.props.showNotification}/>
|
|
</li>
|
|
</ul>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
{ (settings && settings.common && settings.common.notice) && (current_user && current_user.login)?
|
|
<Popover
|
|
overlayClassName="notice-popover"
|
|
placement={`bottomRight`}
|
|
content={<NoticeContent visible={visible} current_user={current_user} showNotification={showNotification} resetUserInfo={resetUserInfo}/>}
|
|
visible={visible}
|
|
onVisibleChange={this.handleVisibleChange}
|
|
destroyTooltipOnHide
|
|
>
|
|
<Link to={"/settings/notice"} className="message-icon mt3">
|
|
{current_user && <Badge count={current_user.message_unread_total}>
|
|
{/* <img src={require(`./img/ring.png`)} alt="" width="16px" className="ml15 mr15"/> */}
|
|
<i className={`iconfont icon-xiaoxilingdang ml20 ${activeIndex?'color-home':'color-grey-6'}`}></i>
|
|
</Badge>}
|
|
</Link>
|
|
</Popover>
|
|
: ""
|
|
}
|
|
<Modal
|
|
keyboard={false}
|
|
title="提示"
|
|
visible={submitapplications}
|
|
closable={false}
|
|
footer={null}
|
|
>
|
|
<div className="task_popup_con ml30">
|
|
<div className="mr15">
|
|
<ul>
|
|
<div className="task-popup-content">
|
|
<p className="task-popup-text-center font-16">
|
|
{submitapplicationsvalue}
|
|
</p>
|
|
</div>
|
|
<li className="clearfix mt10 edu-txt-center">
|
|
<a className="task-btn mr10"
|
|
onClick={this.hidesubmitapplications}>取消</a>
|
|
<a
|
|
className="task-btn task-btn-orange ml20"
|
|
onClick={this.submitsubmitapplications}>确定</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</Modal>
|
|
</div>
|
|
{user === undefined || user.login === "" ?
|
|
<span className="login-box">
|
|
<a onClick={() => this.educoderlogin()} className={`mr5 ${activeIndex ? 'color-home' : 'color-grey-6'}`}>登录</a>
|
|
{
|
|
// settings && settings.new_course && settings.new_course.register_url && (
|
|
activeIndex ?
|
|
<Button className="register-button" type="primary" size="large" ><a href={'/register'}>免费注册</a></Button> :
|
|
<span><em className="vertical-line"></em><a className={`ml5 ${activeIndex ? 'color-home' : 'color-grey-6'}`} href={'/register'} target="_blank">注册</a></span>
|
|
// )
|
|
}
|
|
</span>
|
|
:
|
|
<div className="ml30 edu-menu-panel" style={{ height: "70px", lineHeight: "70px" }}>
|
|
{/* <a href={`/${this.props.current_user === undefined ? "" : this.props.current_user.login}/courses`}> */}
|
|
<img alt="头像" className="radius" height="34" id="nh_user_logo" name="avatar_image"
|
|
src={getImageUrl(user.image_url)} width="34">
|
|
</img>
|
|
{/* </a> */}
|
|
<ul className="edu-menu-list" style={{ top: '60px', textAlign: 'center' }}>
|
|
<li className="bor-bottom-greyE ellipsis-1" style={{cursor:"default",background:"#fff"}}>{this.props.current_user.username}</li>
|
|
{
|
|
settings && settings.personal && settings.personal.length > 0 && settings.personal.map((item,key)=>{
|
|
return(
|
|
<li key={key}><a href={item.url}>{item.name}</a></li>
|
|
)
|
|
})
|
|
}
|
|
<li className="bor-top-greyE">
|
|
<a onClick={() => this.educoderloginysl()}>退出</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default NewHeader;
|