import { loginInfo , routesInfoMap } from '@/store/types' ; export default ( store , router ) => { router . beforeEach ( ( newpath , _oldpath , next ) => { if ( store . state . routesInfoMap [ newpath . name ] && ! store . state . routesInfoMap [ newpath . name ] . public && ! store . state . loginInfo . token ) return next ( { name : 'login' } ) ; const auth = store . state . loginInfo . auth || [ ] ; if ( newpath . name !== 'login' && ! auth . includes ( newpath . name ) && newpath . name !== 'notfound' ) return next ( { name : 'notfound' } ) ; next ( ) ; } ) ; } ;