参考文章:若依框架登录后跳转其他页面&获取不同的菜单&登录进入后跳转至动态路由的第一个路由
需求:登录成功,默认跳转至后端返回的动态路由的第一个路由
src/store/modules/permission.js
将动态路由的第一个路由存到缓存中
 
import cache from '@/plugins/cache'
          let defaultPage='/index'
          //修改默认页面
          if (res.data[0] && res.data[0].children[0] && res.data[0].children[0].children[0]) {
            defaultPage = res.data[0].path + '/' + res.data[0].children[0].path + '/' + res.data[0].children[0].children[0].path
          } else if (res.data[0] && res.data[0].children[0]) {
            defaultPage = res.data[0].path + '/' + res.data[0].children[0].path
          }
          cache.session.set('defaultPage', defaultPage)
src/permission.js
存储上一路由,防止重复跳转
 
import cache from '@/plugins/cache'
       cache.session.set('prePath', from.path)
src/views/index.vue
还保留首页,在首页自动跳转
    gotoMenu() {
      const prePath = this.$cache.session.get('prePath')
      const defaultPage = this.$cache.session.get('defaultPage')
      let permi = checkPermi(['train:trainingrelease:list'])
      if (permi) {
        if (prePath !== '/train/training/trainingrelease') {
          this.$router.push({ path: '/train/training/trainingrelease' }).catch(() => {
          })
        }
      } else if (prePath !== defaultPage) {
        //如果上一页是默认页面,则不跳转到默认页面
        this.$router.push({ path: defaultPage }).catch(() => {
        })
      }
    },
















![[001-03-007].第07节:Redis中的事务](https://i-blog.csdnimg.cn/direct/8a92c260956541bc88191a306689c33f.png)


