|  | @@ -1,3 +1,4 @@
 | 
	
		
			
				|  |  | +import { updateMatch } from '@/store/modules/navigation'
 | 
	
		
			
				|  |  |  import { checkPermission } from '@/store/modules/user'
 | 
	
		
			
				|  |  |  import { RootState } from '@/store/reducers'
 | 
	
		
			
				|  |  |  import { NavigationGuardsProps, RouteModol } from '@/types/router'
 | 
	
	
		
			
				|  | @@ -7,10 +8,11 @@ import { Redirect, Route } from "react-router-dom"
 | 
	
		
			
				|  |  |  import { AnyAction } from 'redux'
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const NavigationGuards:React.FC<NavigationGuardsProps> = props => {
 | 
	
		
			
				|  |  | -  const { location, routeConfig, match, check, permission, isLogin } = props
 | 
	
		
			
				|  |  | +  const { location, routeConfig, match, check, permission, isLogin, saveMatch } = props
 | 
	
		
			
				|  |  |    useEffect(() => {
 | 
	
		
			
				|  |  |      check()
 | 
	
		
			
				|  |  |    }, [])
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    const parentPath: string | null = match?.path || null // 父路由的路径
 | 
	
		
			
				|  |  |    const targetPath: string | null  = location?.pathname || null// 目标路由的位置
 | 
	
		
			
				|  |  |    const targetRoute: RouteModol | null = targetPath && findTargetRoute(parentPath, targetPath, routeConfig) || null
 | 
	
	
		
			
				|  | @@ -30,6 +32,7 @@ const NavigationGuards:React.FC<NavigationGuardsProps> = props => {
 | 
	
		
			
				|  |  |    if (isLogin) {
 | 
	
		
			
				|  |  |      return <LoginHandler targetRoute={targetRoute}></LoginHandler>
 | 
	
		
			
				|  |  |    } else {
 | 
	
		
			
				|  |  | +    saveMatch(targetPath || '/')
 | 
	
		
			
				|  |  |      return <NotLoginHandler targetRoute={targetRoute}></NotLoginHandler>
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -92,16 +95,6 @@ function findTargetRoute (parentPath: any, targetPath: string, routeConfig: Rout
 | 
	
		
			
				|  |  |      const path = combinationPath(parentPath, item.path)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      if (targetPath && switchRoute(path, targetPath)) {
 | 
	
		
			
				|  |  | -      // if (targetPath !== path) {
 | 
	
		
			
				|  |  | -      //   const childRoutes: RouteModol[] = item.childRoutes.map(child => {
 | 
	
		
			
				|  |  | -      //     return { ...child, path: combinationPath(item.path, child.path) }
 | 
	
		
			
				|  |  | -      //   })
 | 
	
		
			
				|  |  | -      //   const routerIdx = childRoutes.findIndex(item => item.path === targetPath)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      //   if (routerIdx !== -1) {
 | 
	
		
			
				|  |  | -      //     return childRoutes[routerIdx]
 | 
	
		
			
				|  |  | -      //   }
 | 
	
		
			
				|  |  | -      // }
 | 
	
		
			
				|  |  |        return { ...item, path }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -143,7 +136,7 @@ function NotLoginHandler(props: any) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const mapStateToProps = (state: RootState) => {
 | 
	
		
			
				|  |  | -  const { permission, isLogin } = state.user
 | 
	
		
			
				|  |  | +  const { user: { permission, isLogin } } = state
 | 
	
		
			
				|  |  |    return {
 | 
	
		
			
				|  |  |      permission,
 | 
	
		
			
				|  |  |      isLogin
 | 
	
	
		
			
				|  | @@ -152,10 +145,12 @@ const mapStateToProps = (state: RootState) => {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const mapDispatchToProps = (dispatch: Dispatch<AnyAction>) => {
 | 
	
		
			
				|  |  |    return {
 | 
	
		
			
				|  |  | -      check: () => {
 | 
	
		
			
				|  |  | +      check() {
 | 
	
		
			
				|  |  |            dispatch(checkPermission())
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      saveMatch(path: string) {
 | 
	
		
			
				|  |  | +        dispatch(updateMatch(path))
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  const connector = connect(mapStateToProps, mapDispatchToProps)
 |