dva 路由权鉴

在路由文件router下session

  history.listen(location => {
        const uid = sessionStorage.getItem('uid') || localStorage.getItem("uid")
        console.log(location.pathname)
        if (location.pathname === '/' || location.pathname === '/login') {
            if (uid) {
                app._store.dispatch(routerRedux.replace('/backstage'))
              }
        }else{
            if(!uid){
                app._store.dispatch(routerRedux.push('/'))
            }
        }

添加全局的路由监听。而后判断跳转。app

这里只能判断本地的路由登陆状况,若是token过时了没法判断ui

相关文章
相关标签/搜索