forked from Gitlink/forgeplus-react
fix
This commit is contained in:
parent
e88c747eca
commit
28f44121ec
|
|
@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
|||
import AccountProfile from "../../modules/user/AccountProfile";
|
||||
import { getImageUrl } from 'educoder'
|
||||
import axios from 'axios';
|
||||
import { Input , notification , Dropdown , Menu, Divider } from 'antd';
|
||||
import { Input, notification, Dropdown, Menu, Divider } from 'antd';
|
||||
import LoginDialog from '../../modules/login/LoginDialog';
|
||||
import AddProjectModal from './AddProjectModal';
|
||||
import '../../modules/tpm/TPMIndex.css';
|
||||
|
|
@ -15,7 +15,7 @@ let old_url;
|
|||
|
||||
window._header_componentHandler = null;
|
||||
// 非trustie链接则新开页跳转
|
||||
const str = ['www.trustie.net','forgeplus.trustie.net','forum.trustie.net','testforgeplus.trustie.net']
|
||||
const str = ['www.trustie.net', 'forgeplus.trustie.net', 'forum.trustie.net', 'testforgeplus.trustie.net']
|
||||
class NewHeader extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
|
@ -41,7 +41,7 @@ class NewHeader extends Component {
|
|||
headtypess: "/",
|
||||
settings: null,
|
||||
visiblemyss: false,
|
||||
openSearch:false,
|
||||
openSearch: false,
|
||||
}
|
||||
}
|
||||
componentDidMount() {
|
||||
|
|
@ -72,38 +72,38 @@ class NewHeader extends Component {
|
|||
//获取游览器地址
|
||||
try {
|
||||
window.sessionStorage.setItem("yslgeturls", JSON.stringify(window.location.href))
|
||||
} catch (e) {}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
SearchInput = (open,item)=>{
|
||||
if(open){
|
||||
return(
|
||||
SearchInput = (open, item) => {
|
||||
if (open) {
|
||||
return (
|
||||
<div
|
||||
onBlur={() => {
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
openSearch:false
|
||||
openSearch: false
|
||||
})
|
||||
}, 300)
|
||||
}}
|
||||
>
|
||||
<Search placeholder="请输入搜索关键字"
|
||||
className={`search-input mr20`}
|
||||
onSearch={(value)=>this.onGlobalSearch(value,item)}
|
||||
onSearch={(value) => this.onGlobalSearch(value, item)}
|
||||
autoFocus={true}
|
||||
style={{width:"260px"}}
|
||||
style={{ width: "260px" }}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}else{
|
||||
} else {
|
||||
return <i className="iconfont icon-sousuo font-18 color-white ml30" onClick={() => {
|
||||
this.setState({openSearch:true})
|
||||
this.setState({ openSearch: true })
|
||||
}} />
|
||||
}
|
||||
}
|
||||
|
||||
onGlobalSearch=(value,item)=>{
|
||||
window.location.href=`${item}?value=` + value;
|
||||
onGlobalSearch = (value, item) => {
|
||||
window.location.href = `${item}?value=` + value;
|
||||
}
|
||||
|
||||
openNotification = (messge) => {
|
||||
|
|
@ -246,61 +246,62 @@ class NewHeader extends Component {
|
|||
|
||||
matchpaths = (url) => {
|
||||
const { match } = this.props;
|
||||
if(url){
|
||||
if (match.path.indexOf(url) > -1) {
|
||||
if (url) {
|
||||
// if (match.path.indexOf(url) > -1) {
|
||||
if (match.path == url) {
|
||||
return true
|
||||
}else {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addMenu=(list)=>{
|
||||
return(
|
||||
list && list.length >0 &&
|
||||
addMenu = (list) => {
|
||||
return (
|
||||
list && list.length > 0 &&
|
||||
<div className="dropdownFlex double">
|
||||
<Menu>
|
||||
<Menu>
|
||||
{
|
||||
list.map((item,key)=>{
|
||||
return(
|
||||
(item.name !=="加入课堂" && item.name !=="加入开发项目") && <Menu.Item><a href={item.url}>{item.name}</a></Menu.Item>
|
||||
list.map((item, key) => {
|
||||
return (
|
||||
(item.name !== "加入课堂" && item.name !== "加入开发项目") && <Menu.Item><a href={item.url}>{item.name}</a></Menu.Item>
|
||||
)
|
||||
})
|
||||
}
|
||||
<Menu.Item><AddProjectModal showNotification={this.props.showNotification}/></Menu.Item>
|
||||
<Menu.Item><AddProjectModal showNotification={this.props.showNotification} /></Menu.Item>
|
||||
</Menu>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
renderMenu=(personal)=>{
|
||||
renderMenu = (personal) => {
|
||||
const { current_user } = this.props;
|
||||
return(
|
||||
return (
|
||||
<Menu className="currentMenu">
|
||||
<Menu.Item>
|
||||
<span title={current_user && current_user.username}>{current_user && current_user.username}</span>
|
||||
</Menu.Item>
|
||||
{
|
||||
personal && personal.length > 0 && personal.map((item,key)=>{
|
||||
return(
|
||||
<li key={key}><a href={item.url} target="_blank">{item.name}</a></li>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
personal && personal.length > 0 && personal.map((item, key) => {
|
||||
return (
|
||||
<li key={key}><a href={item.url} target="_blank">{item.name}</a></li>
|
||||
)
|
||||
})
|
||||
}
|
||||
<Menu.Item><a onClick={() => this.educoderloginysl()}>退出</a></Menu.Item>
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
|
||||
menus=(item)=>{
|
||||
return(
|
||||
menus = (item) => {
|
||||
return (
|
||||
<div className="downMenus">
|
||||
{
|
||||
item.map((i,k)=>{
|
||||
return(
|
||||
!i.hidden && <li onClick={()=>{window.location.href=this.checkLink(i.link)}}>
|
||||
{k!==0 &&<Divider />}
|
||||
item.map((i, k) => {
|
||||
return (
|
||||
!i.hidden && <li onClick={() => { window.location.href = this.checkLink(i.link) }}>
|
||||
{k !== 0 && <Divider />}
|
||||
<aside className="font-16 color-ooo">{i.name}</aside>
|
||||
<div className="font-14" style={{color:"rgb(159, 167, 179)",whiteSpace:'nowrap'}}>{i.content}</div>
|
||||
<div className="font-14" style={{ color: "rgb(159, 167, 179)", whiteSpace: 'nowrap' }}>{i.content}</div>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
|
|
@ -309,7 +310,7 @@ class NewHeader extends Component {
|
|||
)
|
||||
}
|
||||
|
||||
checkLink=(link)=>{
|
||||
checkLink = (link) => {
|
||||
let { settings, } = this.state;
|
||||
if (link) {
|
||||
if (link.indexOf("http") > -1) {
|
||||
|
|
@ -323,7 +324,7 @@ class NewHeader extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { match} = this.props;
|
||||
const { match } = this.props;
|
||||
let current_user = this.props.user;
|
||||
let { Addcoursestypes,
|
||||
tojoinitemtype,
|
||||
|
|
@ -431,78 +432,78 @@ class NewHeader extends Component {
|
|||
{...this.props}
|
||||
{...this.state}
|
||||
/> : ""}
|
||||
{
|
||||
settings && settings.nav_logo_url ?
|
||||
<a href={settings && settings.new_course.default_url} className={"fl mr50"} style={{minWidth:"45px"}}>
|
||||
{
|
||||
settings && settings.nav_logo_url ?
|
||||
<a href={settings && settings.new_course.default_url} className={"fl mr50"} style={{ minWidth: "45px" }}>
|
||||
<img alt="可控开源社区" className="logoimg" style={{ heigth: "40px" }} src={getImageUrl(`/${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) => {
|
||||
// if (!item.link) return;
|
||||
|
||||
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, "users/" + user_login + "/courses")
|
||||
} else if (new_link.indexOf("contests") > -1) {
|
||||
new_link = new_link.replace(/contests/g, "users/" + user_login + "/contests")
|
||||
<ul id="header-nav">
|
||||
{
|
||||
settings.navbar && settings.navbar.map((item, key) => {
|
||||
// if (!item.link) return;
|
||||
|
||||
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, "users/" + user_login + "/courses")
|
||||
} else if (new_link.indexOf("contests") > -1) {
|
||||
new_link = new_link.replace(/contests/g, "users/" + user_login + "/contests")
|
||||
}
|
||||
} else {
|
||||
is_hidden = true
|
||||
}
|
||||
} else {
|
||||
is_hidden = true
|
||||
}
|
||||
}
|
||||
if (user_login && (new_link && new_link.indexOf("homes") > -1)) {
|
||||
new_link = new_link.replace(/homes/g, "users/" + user_login + "/user_activities")
|
||||
}
|
||||
|
||||
var waiLian = (new_link && str.filter(item=>new_link.indexOf(item)>-1) );
|
||||
var wl = waiLian && waiLian.length>0;
|
||||
// if(new_link.indexOf("http")<0){
|
||||
// new_link = settings.new_course.default_url + new_link
|
||||
// }
|
||||
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} target={wl ? "_self":"_blank"}><div dangerouslySetInnerHTML={{ __html: item.name }}></div></a>
|
||||
// </li>
|
||||
<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' }}>
|
||||
{
|
||||
item.subitem && item.subitem.length>0 ?
|
||||
<Dropdown overlay={this.menus(item.subitem)}>
|
||||
<div className="namediv">
|
||||
<a href={this.checkLink(new_link)} target={wl ? "_self":"_blank"}><div dangerouslySetInnerHTML={{ __html: item.name }}></div> </a>
|
||||
<i className="iconfont icon-xiala1 font-14 ml3 mt5 mr3" style={{color:"#979797",fontSize:'14px'}}></i>
|
||||
</div>
|
||||
</Dropdown>
|
||||
:
|
||||
<a href={this.checkLink(new_link)} ><div dangerouslySetInnerHTML={{ __html: item.name }}></div></a>
|
||||
if (user_login && (new_link && new_link.indexOf("homes") > -1)) {
|
||||
new_link = new_link.replace(/homes/g, "users/" + user_login + "/user_activities")
|
||||
}
|
||||
</li>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
: ""
|
||||
|
||||
var waiLian = (new_link && str.filter(item => new_link.indexOf(item) > -1));
|
||||
var wl = waiLian && waiLian.length > 0;
|
||||
// if(new_link.indexOf("http")<0){
|
||||
// new_link = settings.new_course.default_url + new_link
|
||||
// }
|
||||
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} target={wl ? "_self":"_blank"}><div dangerouslySetInnerHTML={{ __html: item.name }}></div></a>
|
||||
// </li>
|
||||
<li key={key} onClick={() => this.headtypesonClick(item.link, true)} className={`${this.matchpaths(item.link.includes("/projects") ? "/projects" : item.link) === true ? 'pr active' : 'pr'}`} style={!is_hidden ? { display: 'flex' } : { display: 'none' }}>
|
||||
{
|
||||
item.subitem && item.subitem.length > 0 ?
|
||||
<Dropdown overlay={this.menus(item.subitem)}>
|
||||
<div className="namediv">
|
||||
<a href={this.checkLink(new_link)} target={wl ? "_self" : "_blank"}><div dangerouslySetInnerHTML={{ __html: item.name }}></div> </a>
|
||||
<i className="iconfont icon-xiala1 font-14 ml3 mt5 mr3" style={{ color: "#979797", fontSize: '14px' }}></i>
|
||||
</div>
|
||||
</Dropdown>
|
||||
:
|
||||
<a href={this.checkLink(new_link)} ><div dangerouslySetInnerHTML={{ __html: item.name }}></div></a>
|
||||
}
|
||||
</li>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
: ""
|
||||
}
|
||||
</div>
|
||||
<div className="head-right">
|
||||
{search_url ? this.SearchInput(openSearch,search_url):""}
|
||||
{search_url ? this.SearchInput(openSearch, search_url) : ""}
|
||||
{
|
||||
current_user && (current_user.main_site || current_user.login) && (settings && settings.add && settings.add.length>0)?
|
||||
<Dropdown overlay={this.addMenu(settings && settings.add)} placement="bottomRight">
|
||||
<i className="iconfont icon-tianjiafangda color-white ml30"></i>
|
||||
</Dropdown>:""
|
||||
current_user && (current_user.main_site || current_user.login) && (settings && settings.add && settings.add.length > 0) ?
|
||||
<Dropdown overlay={this.addMenu(settings && settings.add)} placement="bottomRight">
|
||||
<i className="iconfont icon-tianjiafangda color-white ml30"></i>
|
||||
</Dropdown> : ""
|
||||
}
|
||||
|
||||
|
||||
{this.props.user && this.props.user.login && notice_url ?
|
||||
<div className="ml30 edu-menu-panel">
|
||||
{user && user.login &&
|
||||
|
|
@ -512,10 +513,10 @@ class NewHeader extends Component {
|
|||
</span>
|
||||
</a>
|
||||
}
|
||||
</div>:""
|
||||
</div> : ""
|
||||
}
|
||||
</div>
|
||||
{!user || (user && !user.login) ?
|
||||
{!user || (user && !user.login) ?
|
||||
<span className="font-15 ml30">
|
||||
{(settings && settings.sso_login_url) ? <a className="mr5 color-white" href={settings && settings.sso_login_url}>使用学校统一认证登录</a> :
|
||||
<a onClick={() => this.educoderlogin()} className="mr5 color-white">登录</a>
|
||||
|
|
@ -527,7 +528,7 @@ class NewHeader extends Component {
|
|||
</span>
|
||||
:
|
||||
<Dropdown placement={`bottomRight`} overlay={this.renderMenu(settings && settings.personal)}>
|
||||
<a href={`/users/${this.props.current_user && this.props.current_user.login}`}>
|
||||
<a href={`/users/${this.props.current_user && this.props.current_user.login}`}>
|
||||
<img alt="头像" src={getImageUrl(`/${user.image_url}`)} className="currentImg"></img>
|
||||
</a>
|
||||
</Dropdown>
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ class Index extends Component {
|
|||
<Select
|
||||
showSearch
|
||||
placeholder="请选择语言"
|
||||
style={{ width: "150px", marginRight: "20px" }}
|
||||
style={{ width: "150px" }}
|
||||
size={"large"}
|
||||
onChange={this.changeLanguage}
|
||||
value={languageId}
|
||||
|
|
@ -382,7 +382,7 @@ class Index extends Component {
|
|||
onChange={this.changeSearchValue}
|
||||
/>
|
||||
{current_user && current_user.login &&
|
||||
<Popover content={this.newItem()} trigger={["click"]} placement='bottom' className="mr50">
|
||||
<Popover content={this.newItem()} trigger={["click"]} placement='bottom'>
|
||||
<a style={{ color: "#3061D0" }}>
|
||||
<span className="color-blue font-16"><img src={img_new} alt="" width="13px" /> 新建</span>
|
||||
</a>
|
||||
|
|
|
|||
Loading…
Reference in New Issue