| | |
| | | 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) => { |
| | |
| | | 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') |
| | | } |
| | | } |
| | | }) |