feat: 增加练题

This commit is contained in:
秋水浮尘
2023-12-17 22:03:08 +08:00
parent 0d4f9226c3
commit d0225795da
79 changed files with 10134 additions and 2742 deletions

View File

@@ -1,11 +1,46 @@
import req from '@utils/request'
import Header from '@views/header'
import { Suspense, memo, useEffect } from 'react'
import { useDispatch } from 'react-redux'
import { Outlet, useLocation, useNavigate } from 'react-router-dom'
// 引入对应的方法
import './App.less'
import { saveUserInfo } from './store/features/userInfoSlice.ts'
const apiName = {
update: '/user/update',
queryInfo: '/user/getUserInfo'
}
const App = () => {
const userInfoStorage = localStorage.getItem('userInfo')
const { loginId = '' } = userInfoStorage ? JSON.parse(userInfoStorage) : {}
const dispatch = useDispatch()
const location = useLocation()
const navigate = useNavigate()
const getUserInfo = async () => {
req(
{
method: 'post',
url: apiName.queryInfo,
data: {
userName: loginId
}
},
'/auth'
).then(res => {
if (res?.success && res?.data) {
dispatch(saveUserInfo(res.data))
}
})
}
useEffect(() => {
getUserInfo()
}, [])
useEffect(() => {
if (location.pathname === '/') {
const userInfoStorage = localStorage.getItem('userInfo')
@@ -18,7 +53,7 @@ const App = () => {
return (
<div
className='app-main'
style={{ padding: location.pathname === '/login' ? '66px 0 0' : '66px 16px 32px' }}
style={{ padding: location.pathname === '/login' ? '66px 0 0' : '66px 16px 0' }}
>
<Header />
<div
@@ -29,6 +64,11 @@ const App = () => {
<Outlet />
</Suspense>
</div>
<div className='copyright'>
<a href='http://beian.miit.gov.cn/' target='_blank'>
ICP备2023035579号
</a>
</div>
</div>
)
}