This commit is contained in:
caishi 2021-11-08 15:12:12 +08:00
parent a2ea832208
commit 3085e40426
1 changed files with 92 additions and 95 deletions

View File

@ -16,7 +16,6 @@ import './header.scss';
import NoticeContent from './NoticeContent'; import NoticeContent from './NoticeContent';
const $ = window.$ const $ = window.$
// TODO 这部分脚本从公共脚本中直接调用 // TODO 这部分脚本从公共脚本中直接调用
const { Search } = Input;
let old_url; let old_url;
window._header_componentHandler = null; window._header_componentHandler = null;
@ -56,26 +55,26 @@ class NewHeader extends Component {
window._header_componentHandler = this; window._header_componentHandler = this;
//下拉框的显示隐藏 //下拉框的显示隐藏
var hoverTimeout; // var hoverTimeout;
var hoveredPanel; // var hoveredPanel;
$(".edu-menu-panel").hover(function () { // $(".edu-menu-panel").hover(function () {
if (hoverTimeout) { // 一次只显示一个panel // if (hoverTimeout) { // 一次只显示一个panel
if (hoveredPanel && hoveredPanel !== this) { // if (hoveredPanel && hoveredPanel !== this) {
$(hoveredPanel).find(".edu-menu-list").hide() // $(hoveredPanel).find(".edu-menu-list").hide()
} // }
clearTimeout(hoverTimeout); // clearTimeout(hoverTimeout);
hoverTimeout = null; // hoverTimeout = null;
} // }
hoveredPanel = this; // hoveredPanel = this;
$(this).find(".edu-menu-list").show(); // $(this).find(".edu-menu-list").show();
}, function () { // }, function () {
var that = this; // var that = this;
// 延迟hide // // 延迟hide
hoverTimeout = setTimeout(function () { // hoverTimeout = setTimeout(function () {
$(that).find(".edu-menu-list").hide(); // $(that).find(".edu-menu-list").hide();
}, 800) // }, 800)
}); // });
//获取游览器地址 //获取游览器地址
try { try {
window.sessionStorage.setItem("yslgeturls", JSON.stringify(window.location.href)) window.sessionStorage.setItem("yslgeturls", JSON.stringify(window.location.href))
@ -279,92 +278,90 @@ class NewHeader extends Component {
}; };
render() { render() {
const { match ,resetUserInfo ,showNotification,publicNav} = this.props; const { resetUserInfo ,showNotification,publicNav} = this.props;
let current_user = this.props.user; let current_user = this.props.user;
let { let {
AccountProfiletype, AccountProfiletype,
user, user,
isRender, isRender,
headtypesonClickbool,
headtypess,
settings, settings,
visible, visible,
} = this.state; } = this.state;
/*用户名称 用户头像url*/ /*用户名称 用户头像url*/
let activeIndex = false; // let activeIndex = false;
let activeForums = false; // let activeForums = false;
let activeShixuns = false; // let activeShixuns = false;
let activePaths = false; // let activePaths = false;
let coursestype = false; // let coursestype = false;
let activePackages = false; // let activePackages = false;
let activeMoopCases = false; // let activeMoopCases = false;
let activeCompetitions = false; // let activeCompetitions = false;
if (match.path === '/forums') { // if (match.path === '/forums') {
activeForums = true; // activeForums = true;
} else if (match.path.startsWith('/shixuns')) { // } else if (match.path.startsWith('/shixuns')) {
activeShixuns = true; // activeShixuns = true;
} else if (match.path.startsWith('/paths')) { // } else if (match.path.startsWith('/paths')) {
activePaths = true; // activePaths = true;
} else if (match.path.startsWith('/courses')) { // } else if (match.path.startsWith('/courses')) {
coursestype = true; // coursestype = true;
} else if (match.path.startsWith('/crowdsourcing')) { // } else if (match.path.startsWith('/crowdsourcing')) {
activePackages = true; // activePackages = true;
} else if (match.path.startsWith('/moop_cases')) { // } else if (match.path.startsWith('/moop_cases')) {
activeMoopCases = true; // activeMoopCases = true;
} else if (match.path.startsWith('/competitions')) { // } else if (match.path.startsWith('/competitions')) {
activeCompetitions = true; // activeCompetitions = true;
} else { // } else {
activeIndex = true; // activeIndex = true;
} // }
let headtypes = '/'; // let headtypes = '/';
if (settings) { // if (settings) {
if (settings.navbar) { // if (settings.navbar) {
if (settings.navbar.length > 0) { // if (settings.navbar.length > 0) {
if (match.path === '/') { // if (match.path === '/') {
if (headtypesonClickbool === false) { // if (headtypesonClickbool === false) {
headtypes = undefined; // headtypes = undefined;
} else { // } else {
headtypes = headtypess; // headtypes = headtypess;
} // }
} else { // } else {
for (var i = 0; i < settings.navbar.length; i++) { // for (var i = 0; i < settings.navbar.length; i++) {
if (match.path === settings.navbar[i].link) { // if (match.path === settings.navbar[i].link) {
headtypes = settings.navbar[i].link; // headtypes = settings.navbar[i].link;
break; // break;
} // }
} // }
} // }
} // }
} // }
} // }
let shixuntype = false; // let shixuntype = false;
let pathstype = false; // let pathstype = false;
let coursestypes = false; // let coursestypes = false;
if (this.props && this.props.mygetHelmetapi != null) { // if (this.props && this.props.mygetHelmetapi != null) {
let shixun = "/shixuns"; // let shixun = "/shixuns";
let paths = "/paths"; // let paths = "/paths";
let courses = "/courses"; // let courses = "/courses";
this.props.mygetHelmetapi && this.props.mygetHelmetapi.navbar && this.props.mygetHelmetapi.navbar.map((item, key) => { // this.props.mygetHelmetapi && this.props.mygetHelmetapi.navbar && this.props.mygetHelmetapi.navbar.map((item, key) => {
var reg = RegExp(item.link); // var reg = RegExp(item.link);
if (shixun.match(reg)) { // if (shixun.match(reg)) {
if (item.hidden === true) { // if (item.hidden === true) {
shixuntype = true // shixuntype = true
} // }
} // }
if (paths.match(reg)) { // if (paths.match(reg)) {
if (item.hidden === true) { // if (item.hidden === true) {
pathstype = true // pathstype = true
} // }
} // }
if (courses.match(reg)) { // if (courses.match(reg)) {
if (item.hidden === true) { // if (item.hidden === true) {
coursestypes = true // coursestypes = true
} // }
} // }
}) // })
} // }
let search_url = settings && settings.common && settings.common.search; let search_url = settings && settings.common && settings.common.search;
return ( return (