diff --git a/src/components/Header/index.less b/src/components/Header/index.less index 22af26f1f..400e81934 100755 --- a/src/components/Header/index.less +++ b/src/components/Header/index.less @@ -120,3 +120,39 @@ width: 80px; // box-shadow: 0 0 5px rgba(0, 255, 249, 0.6); } +.dropLi{ + display: flex; + flex-direction: column; + align-items: center; + .dropDown { + position: fixed; + top: 58px; + background-color: #ffffff; + border-bottom-left-radius: 10px; + border-bottom-right-radius: 10px; + transition: height 0.2s ease-in-out; + overflow: hidden; + padding-left: 0px!important; + box-shadow:0px 0px 6px rgba(6, 44, 107, 0.15); + .dropDownItem { + height: 46px !important; + line-height: 46px !important; + padding-right:unset; + position: relative; + margin-right: 0px!important; + padding:0px 20px; + a { + color: #252b3a !important; + display: inline-block; + height: 100%; + max-width: 160px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + &:hover { + background-color: #ebf0ff; + } + } + } +} \ No newline at end of file diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index cdd82611d..a0bf3d8de 100755 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -97,6 +97,8 @@ const HeaderComponents: FC = ({ const [openSearch, setOpenSearch] = useState(false) const [activeKey, setActiveKey] = useState(-1) const [QQVisible, setQQVisible] = useState(false) + const [ zoneList , setZoneList ] = useState<[]>() + const [ showSubMenu , setShowSubMenu ] = useState(false); const payload = getCourseParam() let pathname = location.pathname; useEffect(() => { @@ -106,9 +108,30 @@ const HeaderComponents: FC = ({ ...payload, }, }) + getZoneList(); }, [globalSetting.name]) - - // console.log('-----------',location.pathname==='/classrooms'?'1':'2'); + const { userInfo } = user; + + + // 获取特色专区列表 + async function getZoneList(){ + let res = await dispatch({ + type: 'user/ForgeGetZoneList', + payload: { + ...payload, + }, + }) + if(res?.data){ + let newArray:any = []; + res.data.forEach((e:any, i:number) => { + newArray[i] = { + name: e.name, + link: `/zone/${e.key}` + } + }); + setZoneList(newArray); + } + } useEffect(() => { @@ -257,7 +280,24 @@ const HeaderComponents: FC = ({ v: { name: string, link: string, hidden: boolean }, k: number, ) { - if (!v.hidden) { + if (v.name === '特色专区') { + // 特色专区下拉菜单 + return zoneList && zoneList.length > 0 ?
  • { setShowSubMenu(true) } } + onMouseOut={ () => { setShowSubMenu(false) } } + > + { setShowSubMenu(true) } }>特色专区 + +
  • : '' + } else { return (
  • = ({ ? styles.actived : '' } + style={{display:v?.hidden?"none":"flex"}} > {v?.name === '教学课堂' && { if (localStorage.getItem('Noviceguide') === '0') { @@ -282,7 +323,6 @@ const HeaderComponents: FC = ({ }, }) } - }} className={shixunHomeworks.actionTabs.type === 4 ? styles.classromediv : ''} dangerouslySetInnerHTML={{ __html: v.name }} to={v.link}>} {v?.name != '教学课堂' && v.link.indexOf("http") < 0 && { dispatch({ diff --git a/src/models/user/index.ts b/src/models/user/index.ts index dc14a5889..c873c6424 100755 --- a/src/models/user/index.ts +++ b/src/models/user/index.ts @@ -1,6 +1,6 @@ import { Effect, Reducer, Subscription, history } from 'umi' import { Action } from '@@/plugin-dva/connect' -import { LoginIn, getUserInfo, getNavigationInfo , ForgeLogin , getEducoderUserInfo , ForgeCheckName , ForgeSaveUserInfo , ForgeCheckEmail } from '@/service/user' +import { LoginIn, getUserInfo, getNavigationInfo , getZoneList , ForgeLogin , getEducoderUserInfo , ForgeCheckName , ForgeSaveUserInfo , ForgeCheckEmail } from '@/service/user' export interface UserModelState { name: string @@ -26,7 +26,8 @@ export interface UserModelType { getEducoderUserInfo:Effect, ForgeCheckName:Effect, ForgeCheckEmail:Effect, - ForgeSaveUserInfo:Effect + ForgeSaveUserInfo:Effect, + ForgeGetZoneList:Effect } reducers: { save: Reducer @@ -109,6 +110,10 @@ const UserModel: UserModelType = { }) return response; }, + *ForgeGetZoneList({ payload }, { call, put }) { + const response = yield call(getZoneList, { ...payload}) + return response; + }, *getNavigationInfo({ payload }, { call, put }) { const response = yield call(getNavigationInfo, { ...payload }) yield put({ diff --git a/src/pages/Competitions/Index/index.less b/src/pages/Competitions/Index/index.less index b8a0162eb..aee9c20b5 100755 --- a/src/pages/Competitions/Index/index.less +++ b/src/pages/Competitions/Index/index.less @@ -8,8 +8,14 @@ overflow: hidden; .flex_box_container(); .flex_box_center(); + a{ + display: block; + width: 100%; + } img { height: 300px; + width: 100%; + object-fit: cover; } } .info{ diff --git a/src/service/user.ts b/src/service/user.ts index 5b71af970..85553384e 100755 --- a/src/service/user.ts +++ b/src/service/user.ts @@ -1,6 +1,11 @@ import Fetch from '@/utils/fetch'; import ENV from '@/utils/env'; +export async function getZoneList() { + return Fetch(`${ENV.ZONE_SERVER}/api/zone/open/list`, { + method: 'get' + }); +} export async function ForgeLogin(params: any) { return Fetch(`${ENV.FORGE_SERVER}/api/accounts/login.json`, { method: 'post', diff --git a/src/utils/env.ts b/src/utils/env.ts index 0b7db4b03..c712864b4 100755 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -17,6 +17,7 @@ export interface ConfigProps { FORGE: String QQLoginCB: string, FORGE_SERVER:string, + ZONE_SERVER:string } } @@ -28,29 +29,11 @@ export const GlobalConfig: ConfigProps = { FORGE: "https://test-oldweb.educoder.net/", SSH_SERVER: "wss://pre-webssh.educoder.net", QQLoginCB: encodeURIComponent("https://test-newweb.educoder.net"), - FORGE_SERVER:"https://testforgeplus.trustie.net" + FORGE_SERVER:"https://testforgeplus.trustie.net", + ZONE_SERVER:"https://gateway.gitlink.org.cn" }, dev: DEV, - newReactTest: { - // API_SERVER: 'https://test-data.educoder.net', - API_SERVER: ((() => { - let api = 'https://test-data.educoder.net' - const domain = document.domain - let str = document.domain.split(".") - str[0] = str[0] + "-data"; - if (domain !== 'test.educoder.net' && domain !== 'localhost') { - api = api.replace("test-data.educoder.net", str.join(".")) - } - return api - })()), - SSH_SERVER: "wss://webssh.educoder.net", - IMG_SERVER: 'https://new-testali-cdn.educoder.net', - REPORT_SERVER: "http://192.168.1.57:3001", - FORGE: "https://test-oldweb.educoder.net/", - QQLoginCB: encodeURIComponent("https://test-data.educoder.net"), - FORGE_SERVER:"https://testforgeplus.trustie.net" - }, preNewBuild: { API_SERVER: 'https://pre-data.educoder.net', // API_SERVER: ((() => { @@ -68,7 +51,8 @@ export const GlobalConfig: ConfigProps = { REPORT_SERVER: "http://192.168.1.57:3001", FORGE: "https://forge.educoder.net/", QQLoginCB: encodeURIComponent("https://pre.educoder.net"), - FORGE_SERVER:"https://testforgeplus.trustie.net" + FORGE_SERVER:"https://testforgeplus.trustie.net", + ZONE_SERVER:"https://gateway.gitlink.org.cn" }, newBuild: { // API_SERVER: 'https://data.educoder.net', @@ -87,17 +71,8 @@ export const GlobalConfig: ConfigProps = { IMG_SERVER: 'https://test-data.educoder.net/', FORGE: "https://code.educoder.net/", QQLoginCB: encodeURIComponent("https://www.educoder.net"), - FORGE_SERVER:"https://testforgeplus.educoder.cn" - }, - // test - newTest: { - API_SERVER: 'https://test-data.educoder.net', - IMG_SERVER: 'https://test-data.educoder.net', - REPORT_SERVER: "http://192.168.1.57:3001", - SSH_SERVER: "wss://pre-webssh.educoder.net", - FORGE: "http://test-oldweb.educoder.net/", - QQLoginCB: encodeURIComponent("https://test-data.educoder.net"), - FORGE_SERVER:"https://testforgeplus.trustie.net" + FORGE_SERVER:"https://testforgeplus.educoder.cn", + ZONE_SERVER:"https://gateway.gitlink.org.cn" }, test: { API_SERVER: 'https://test-data.educoder.net/', @@ -106,25 +81,8 @@ export const GlobalConfig: ConfigProps = { FORGE: "http://test-oldweb.educoder.net/", SSH_SERVER: "wss://pre-webssh.educoder.net", QQLoginCB: encodeURIComponent("https://test-newweb.educoder.net"), - FORGE_SERVER:"https://testforgeplus.educoder.net" - }, - preBuild: { - API_SERVER: 'https://pre-data.educoder.net', - IMG_SERVER: 'https://preali-cdn.educoder.net', - REPORT_SERVER: "http://192.168.1.57:3001", - FORGE: "https://forge.educoder.net/", - SSH_SERVER: "wss://pre-webssh.educoder.net", - QQLoginCB: encodeURIComponent("https://test-newweb.educoder.net"), - FORGE_SERVER:"https://pre.gitlink.org.cn", - }, - newWeb: { - API_SERVER: 'https://test-newweb.educoder.net', - IMG_SERVER: 'https://test-newweb.educoder.net/', - REPORT_SERVER: "http://192.168.1.57:3001", - FORGE: "http://test-oldweb.educoder.net/", - SSH_SERVER: "wss://pre-webssh.educoder.net", - QQLoginCB: encodeURIComponent("https://test-newweb.educoder.net"), - FORGE_SERVER:"https://testforgeplus.educoder.net" + FORGE_SERVER:"https://testforgeplus.educoder.net", + ZONE_SERVER:"https://gateway.gitlink.org.cn" }, build: { API_SERVER: 'https://data.educoder.net', @@ -134,6 +92,7 @@ export const GlobalConfig: ConfigProps = { SSH_SERVER: "wss://webssh.educoder.net", QQLoginCB: encodeURIComponent("https://www.educoder.net"), FORGE_SERVER:"https://www.gitlink.org.cn", + ZONE_SERVER:"https://gateway.gitlink.org.cn" }, }; export default GlobalConfig[window.ENV || "dev"] diff --git a/src/utils/env/dev.ts b/src/utils/env/dev.ts index e0dad134b..5cf12af70 100644 --- a/src/utils/env/dev.ts +++ b/src/utils/env/dev.ts @@ -6,7 +6,8 @@ export const DEV = { FORGE: "https://code.educoder.net/", SSH_SERVER:"wss://webssh.educoder.net", QQLoginCB: encodeURIComponent("https://test-newweb.educoder.net"), - FORGE_SERVER:"https://testforgeplus.trustie.net" + FORGE_SERVER:"https://testforgeplus.trustie.net", + ZONE_SERVER:"https://gateway.gitlink.org.cn" } export default DEV \ No newline at end of file