feat: 新增菜单图标, 搜索组件

This commit is contained in:
wenhua
2023-11-10 14:31:25 +08:00
parent 2eeaf31cf4
commit ff24a5cec9
52 changed files with 11561 additions and 34 deletions

View File

@@ -1,8 +1,5 @@
import { Navigate } from "react-router-dom"
import { getToken } from "../utils/auth"
import { useDispatch, useSelector } from "react-redux"
import { addRoutes, getAsyncRouters } from "../stores/permission"
import { addAuthInfo, getAuthInfo } from "../stores/auth"
const Views = import.meta.glob('../view/**/*.tsx')
// 判断是否有对应路径的映射文件
@@ -16,33 +13,15 @@ const hasMapFile = (filePath: string): boolean => {
* @param {children: ReactDOM, filePath: string(文件路径)}
*/
export default function RouteInterception({ children, filePath = "" }: any) {
const routes: [] = useSelector((store: any) => store.permission)
const dispatch = useDispatch()
const requestAsyncRoutes = async () => {
const { payload } = await dispatch(getAsyncRouters() as any)
dispatch(addRoutes(payload))
}
const requestAuthInfo = async () => {
const {payload} = await dispatch(getAuthInfo() as any)
dispatch(addAuthInfo(payload))
}
if (getToken()) {
if (!routes.length) {
requestAsyncRoutes()
requestAuthInfo()
} else {
if (filePath !== "") {
if (hasMapFile(filePath)) {
return children
} else {
return <Navigate to='/404' />
}
if (filePath !== "") {
if (hasMapFile(filePath)) {
return children
} else {
return <Navigate to='/404' />
}
return children
}
return children
} else {
return <Navigate to='/login' replace={true} />
}