智慧农业后台管理页面
guoshilong
2022-08-30 fd4f992586b0436bc2665c371c34c142aec4bc53
src/permission.js
@@ -8,8 +8,6 @@
import {getToken} from '@/util/auth'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import {loginInfoByToken} from '@/api/user'
import {Message} from "element-ui";
NProgress.configure({showSpinner: false});
const lockPage = store.getters.website.lockPage; //锁屏页
router.beforeEach((to, from, next) => {
@@ -59,30 +57,7 @@
    if (meta.isAuth === false) {
      next()
    } else {
      // 需要判断是否单点登录
      let token = window.sessionStorage.getItem('token')
      if (token) {
        loginInfoByToken.then(res => {
          const data = res.data;
          if (data.error_description) {
            Message({
              message: data.error_description,
              type: 'error'
            })
          } else {
            this.$store.commit('SET_TOKEN', data.access_token);
            this.$store.commit('SET_REFRESH_TOKEN', data.refresh_token);
            this.$store.commit('SET_TENANT_ID', data.tenant_id);
            this.$store.commit('SET_USER_INFO', data);
            this.$store.commit('DEL_ALL_TAG');
            this.$store.commit('CLEAR_LOCK');
            next(to.path)
          }
        })
      } else {
        next('/login')
      }
      next('/login')
    }
  }
})