feat: 联调
This commit is contained in:
@@ -1,38 +1,37 @@
|
||||
import { message } from 'antd';
|
||||
import React, { useState, memo, useEffect } from 'react'
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { message } from 'antd'
|
||||
import React, { memo, useEffect, useState } from 'react'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import './index.less'
|
||||
// 顶部tab
|
||||
const MENULIST = [
|
||||
{
|
||||
key: 'questionBank',
|
||||
title: '刷题',
|
||||
route: '/question-bank',
|
||||
route: '/question-bank'
|
||||
},
|
||||
{
|
||||
key: 'prictiseQuestion',
|
||||
title: '练题',
|
||||
route: '/brush-question',
|
||||
route: '/brush-question'
|
||||
},
|
||||
{
|
||||
key: 'practiceQuestions',
|
||||
title: '鸡圈',
|
||||
route: '/practice-questions',
|
||||
route: '/practice-questions'
|
||||
},
|
||||
{
|
||||
key: 'interList',
|
||||
title: '模拟面试',
|
||||
route: '/inter-list',
|
||||
},
|
||||
route: '/inter-list'
|
||||
}
|
||||
]
|
||||
|
||||
// 顶部tab映射
|
||||
const mapMenu = {
|
||||
'/question-bank': 'questionBank',
|
||||
'/question-bank': 'questionBank'
|
||||
}
|
||||
|
||||
const TopMenu = () => {
|
||||
|
||||
const [currentKey, setCurrentKey] = useState('questionBank')
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
@@ -44,26 +43,29 @@ const TopMenu = () => {
|
||||
} else {
|
||||
setCurrentKey('')
|
||||
}
|
||||
}, [location.pathname]);
|
||||
|
||||
}, [location.pathname])
|
||||
|
||||
/**
|
||||
* 切换item
|
||||
* @param {*} item
|
||||
* @returns
|
||||
*/
|
||||
const changeMenu = (item) => () => {
|
||||
if (item.key === "questionBank") {
|
||||
const changeMenu = item => () => {
|
||||
const userInfoStorage = localStorage.getItem('userInfo')
|
||||
if (!userInfoStorage) {
|
||||
return message.info('请登录')
|
||||
}
|
||||
if (item.key === 'questionBank') {
|
||||
if (location.pathname === '/question-bank') return
|
||||
navigate('/question-bank')
|
||||
setCurrentKey(item.key)
|
||||
} else {
|
||||
return message.info("敬请期待")
|
||||
return message.info('敬请期待')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="top-menu-list">
|
||||
<div className='top-menu-list'>
|
||||
{MENULIST.map((item, index) => {
|
||||
return (
|
||||
<div
|
||||
@@ -71,8 +73,10 @@ const TopMenu = () => {
|
||||
key={item.key + index}
|
||||
onClick={changeMenu(item)}
|
||||
>
|
||||
<div className="top-menu-text">{item.title}</div>
|
||||
<div className={`top-menu-line ${currentKey === item.key ? 'top-menu-line-active' : ''}`}></div>
|
||||
<div className='top-menu-text'>{item.title}</div>
|
||||
<div
|
||||
className={`top-menu-line ${currentKey === item.key ? 'top-menu-line-active' : ''}`}
|
||||
></div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
Reference in New Issue
Block a user