From 1bcf07b20cef81b9e9b8d7ba59d0ead8fd2642ab Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 25 Apr 2024 09:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=89=B9=E8=89=B2=E4=B8=93?= =?UTF-8?q?=E5=8C=BA=E4=B8=8B=E6=8B=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/env.js | 10 ++-- package.json | 6 +-- public/css/edu-all.css | 26 +++++----- public/css/edu-purge.css | 14 +++--- src/modules/tpm/NewHeader.js | 93 ++++++++++++++++++++++++++---------- src/modules/tpm/TPMIndex.css | 34 +++++++++++++ 6 files changed, 129 insertions(+), 54 deletions(-) diff --git a/config/env.js b/config/env.js index 8e68efe00..84d9446b1 100644 --- a/config/env.js +++ b/config/env.js @@ -8,11 +8,11 @@ const paths = require('./paths'); delete require.cache[require.resolve('./paths')]; const NODE_ENV = process.env.NODE_ENV; -if (!NODE_ENV) { - throw new Error( - 'The NODE_ENV environment variable is required but was not specified.' - ); -} +// if (!NODE_ENV) { +// throw new Error( +// 'The NODE_ENV environment variable is required but was not specified.' +// ); +// } // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use var dotenvFiles = [ diff --git a/package.json b/package.json index f8f3a321f..a59494502 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "educoder", - "version": "0.1.0", + "name": "luntan", + "version": "1.1.0", "private": true, "dependencies": { "@monaco-editor/react": "^2.3.0", @@ -118,7 +118,7 @@ }, "scripts": { "start": "node --max_old_space_size=15360 scripts/start.js", - "build": "NODE_ENV=production node --max_old_space_size=15360 scripts/build.js", + "build": "node --max_old_space_size=15360 scripts/build.js", "test-build": "NODE_ENV=testBuild node --max_old_space_size=15360 scripts/build.js", "pre-build": "NODE_ENV=preBuild node --max_old_space_size=15360 scripts/build.js", "gen_stats": "NODE_ENV=production webpack --profile --config=./config/webpack.config.prod.js --json > stats.json", diff --git a/public/css/edu-all.css b/public/css/edu-all.css index b8a558075..6d5ae6108 100644 --- a/public/css/edu-all.css +++ b/public/css/edu-all.css @@ -38,7 +38,7 @@ box-sizing: border-box; } -.head-nav ul#header-nav li { +.head-nav ul#header-nav > li { float: left; height: 60px; line-height: 60px; @@ -48,57 +48,57 @@ font-size: 16px } -.head-nav ul#header-nav li a { +.head-nav ul#header-nav > li a { display: block; height: 100%; width: 100%; color: #fff } -.head-nav ul#header-nav li a:hover { +.head-nav ul#header-nav > li a:hover { color: #cccccc; } -.head-nav ul#header-nav li:last-child { +.head-nav ul#header-nav > li:last-child { margin-right: 0px } -.head-nav ul#header-nav li.active a { +.head-nav ul#header-nav > li.active a { color: #459be5 !important; } -.head-nav ul#header-nav li.active p { +.head-nav ul#header-nav > li.active p { color: #459be5 !important; } -.head-nav ul#header-nav li p:hover { +.head-nav ul#header-nav > li p:hover { color: #cccccc; } -.head-nav ul#header-nav li p { +.head-nav ul#header-nav > li p { display: block; height: 100%; width: 100%; color: #fff } -.head-nav ul#header-nav li.active div ul li a { +.head-nav ul#header-nav > li.active div ul li a { color: #000 !important; } -.head-nav ul#header-nav li.active div ul li a:hover { +.head-nav ul#header-nav > li.active div ul li a:hover { color: #FFF !important; } -.head-nav ul#header-nav li.active ul li a { +.head-nav ul#header-nav > li.active ul li a { color: #000 !important; } -.head-nav ul#header-nav li.active ul li a:hover { +.head-nav ul#header-nav > li.active ul li a:hover { color: #FFF !important; } -.head-nav ul#header-nav li.active:after { +.head-nav ul#header-nav > li.active:after { content: ''; position: absolute; left: 0px; diff --git a/public/css/edu-purge.css b/public/css/edu-purge.css index 9b73c8ead..d9499898c 100644 --- a/public/css/edu-purge.css +++ b/public/css/edu-purge.css @@ -3997,7 +3997,7 @@ html>body #ajax-indicator { box-sizing: border-box; } -.head-nav ul#header-nav li { +.head-nav ul#header-nav > li { float: left; height: 58px; line-height: 58px; @@ -4007,7 +4007,7 @@ html>body #ajax-indicator { padding:0px 20px; } -.head-nav ul#header-nav li a { +.head-nav ul#header-nav > li a { display: block; height: 100%; width: 100%; @@ -4015,24 +4015,24 @@ html>body #ajax-indicator { font-size: 16px; } -.head-nav ul#header-nav li a:hover,.head-nav ul#header-nav li.active a { +.head-nav ul#header-nav > li a:hover,.head-nav ul#header-nav > li.active a { color: #5091FF; } -.head-nav ul#header-nav li:last-child { +.head-nav ul#header-nav > li:last-child { margin-right: 0px } -.head-nav ul#header-nav li.active{ +.head-nav ul#header-nav > li.active{ /* background-color: #3B3B3B; */ } -.head-nav ul#header-nav li p:hover { +.head-nav ul#header-nav > li p:hover { color: #cccccc; } -.head-nav ul#header-nav li p { +.head-nav ul#header-nav > li p { display: block; height: 100%; width: 100%; diff --git a/src/modules/tpm/NewHeader.js b/src/modules/tpm/NewHeader.js index b01beda6c..020905ea3 100644 --- a/src/modules/tpm/NewHeader.js +++ b/src/modules/tpm/NewHeader.js @@ -14,11 +14,9 @@ import 'antd/lib/input/style/index.css'; import './TPMIndex.css'; import logo from './images/logo.png'; +let old_url ; const $ = window.$ -// TODO 这部分脚本从公共脚本中直接调用 -const { Search } = Input; -let old_url; - +const gitlinkUrl = `https://www.gitlink.org.cn`; window._header_componentHandler = null; class NewHeader extends Component { constructor(props) { @@ -48,7 +46,9 @@ class NewHeader extends Component { mygetHelmetapi2: null, goshowqqgtounp: false, visiblemyss: false, - navbar: [] + navbar: [], + showSubMenu:false, + zoneList:[] } } componentDidMount() { @@ -81,6 +81,27 @@ class NewHeader extends Component { try { window.sessionStorage.setItem("yslgeturls", JSON.stringify(window.location.href)) } catch (e) {} + + this.getZoneList() + } + + // 获取专区下拉 + getZoneList = () =>{ + const url = `https://gateway.gitlink.org.cn/api/zone/open/list` + axios.get(url).then((response) => { + if (response && response.data && response.data.data && response.data.data.length > 0) { + let newArray = []; + response.data.data.forEach((e, i) => { + newArray[i] = { + name: e.name, + link: `/zone/${e.key}` + } + }); + this.setState({ zoneList: newArray }) + } else { + } + }).catch((error) => { + }); } openNotification = (messge) => { @@ -644,6 +665,8 @@ class NewHeader extends Component { isRender, mygetHelmetapi2, goshowqqgtounp, + zoneList, + showSubMenu, navbar } = this.state; @@ -685,30 +708,48 @@ class NewHeader extends Component { { navbar && navbar.map((item, key) => { var new_link = item.link; - var user_login = this.props.user && this.props.user.login; + // 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 - } - } - if (user_login && (new_link && new_link.indexOf("homes") > -1)) { - new_link = new_link.replace(/homes/g, "users/" + user_login + "/user_activities") - } + // 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 + // } + // } + // if (user_login && (new_link && new_link.indexOf("homes") > -1)) { + // new_link = new_link.replace(/homes/g, "users/" + user_login + "/user_activities") + // } if (item.name === '特色专区') { - is_hidden = true + return( + // 特色专区下拉菜单 + zoneList && zoneList.length > 0 ?