dva 路由权鉴

在路由文件router下

  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('/'))
            }
        }

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

这里只能判断本地的路由登录情况,如果token过期了无法判断

posted @ 2019-01-28 22:52  星陨的菲  阅读(674)  评论(0编辑  收藏  举报