permission.js 662 B

12345678910111213141516171819202122232425
  1. import router from './router'
  2. import { getToken, setToken } from '@/utils/auth' // getToken from cookie
  3. //路由跳转之前
  4. router.beforeEach((to, _from, next) => {
  5. const path = to.path;
  6. const Authorization = to.query.Authorization
  7. if (path=='/auth' && Authorization) {
  8. setToken(Authorization);
  9. // console.log(Authorization);
  10. next({ path: '/' });
  11. }else{
  12. const token = getToken();
  13. if( token && token != 'undefined' ){
  14. next();
  15. }else{
  16. // window.location.href = 'http://dgt.dgtis.com/oneportal/login'
  17. window.location.href = 'http://192.168.100.208:8080/oneportal/login'
  18. }
  19. }
  20. })
  21. router.afterEach(() => {})