From 28f44121ec2a4fd274fe5e7c2b0eae67c6174b9f Mon Sep 17 00:00:00 2001 From: helinfeng <82085299+itfxl@users.noreply.github.com> Date: Fri, 27 Jun 2025 10:35:55 +0800 Subject: [PATCH] fix --- src/forge/Head/Header.js | 207 ++++++++++++++++++++------------------- src/forge/Main/Index.js | 4 +- 2 files changed, 106 insertions(+), 105 deletions(-) diff --git a/src/forge/Head/Header.js b/src/forge/Head/Header.js index 075278079..850a3cc99 100644 --- a/src/forge/Head/Header.js +++ b/src/forge/Head/Header.js @@ -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 (
{ setTimeout(() => { this.setState({ - openSearch:false + openSearch: false }) }, 300) }} > this.onGlobalSearch(value,item)} + onSearch={(value) => this.onGlobalSearch(value, item)} autoFocus={true} - style={{width:"260px"}} + style={{ width: "260px" }} />
) - }else{ + } else { return { - 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 &&
- + { - list.map((item,key)=>{ - return( - (item.name !=="加入课堂" && item.name !=="加入开发项目") && {item.name} + list.map((item, key) => { + return ( + (item.name !== "加入课堂" && item.name !== "加入开发项目") && {item.name} ) }) } - +
) } - renderMenu=(personal)=>{ + renderMenu = (personal) => { const { current_user } = this.props; - return( + return ( {current_user && current_user.username} - { - personal && personal.length > 0 && personal.map((item,key)=>{ - return( -
  • {item.name}
  • - ) - }) - } + { + personal && personal.length > 0 && personal.map((item, key) => { + return ( +
  • {item.name}
  • + ) + }) + } this.educoderloginysl()}>退出
    ) } - menus=(item)=>{ - return( + menus = (item) => { + return (
    { - item.map((i,k)=>{ - return( - !i.hidden &&
  • {window.location.href=this.checkLink(i.link)}}> - {k!==0 &&} + item.map((i, k) => { + return ( + !i.hidden &&
  • { window.location.href = this.checkLink(i.link) }}> + {k !== 0 && } -
    {i.content}
    +
    {i.content}
  • ) }) @@ -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 ? - + { + settings && settings.nav_logo_url ? + 可控开源社区 : "" - } + }
    { settings && settings.navbar && settings.navbar.length > 0 ? -
      - { - 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") +
        + { + 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 ( - //
      • this.headtypesonClick(item.link, true)} className={`${this.matchpaths(item.link) === true ? 'pr active' : 'pr'}`} style={!is_hidden ? { display: 'flex' } : { display: 'none' }}> - //
        - //
      • -
      • 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 ? - -
        -
        - -
        -
        - : -
        + 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 ( + //
    • this.headtypesonClick(item.link, true)} className={`${this.matchpaths(item.link) === true ? 'pr active' : 'pr'}`} style={!is_hidden ? { display: 'flex' } : { display: 'none' }}> + //
      + //
    • +
    • 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 ? + +
      +
      + +
      +
      + : +
      + } +
    • + ) + }) + } +
    + : "" }
    - {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)? - - - :"" + current_user && (current_user.main_site || current_user.login) && (settings && settings.add && settings.add.length > 0) ? + + + : "" } - + {this.props.user && this.props.user.login && notice_url ?
    {user && user.login && @@ -512,10 +513,10 @@ class NewHeader extends Component { } -
    :"" +
    : "" }
    - {!user || (user && !user.login) ? + {!user || (user && !user.login) ? {(settings && settings.sso_login_url) ? 使用学校统一认证登录 : this.educoderlogin()} className="mr5 color-white">登录 @@ -527,7 +528,7 @@ class NewHeader extends Component { : - + 头像 diff --git a/src/forge/Main/Index.js b/src/forge/Main/Index.js index 625c59a21..8ccf5e7f2 100644 --- a/src/forge/Main/Index.js +++ b/src/forge/Main/Index.js @@ -353,7 +353,7 @@ class Index extends Component {