permission.js 711 B

123456789101112131415161718192021222324252627
  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.indexOf('auth') != -1 && 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. //本地地址
  17. location.href = 'http://192.168.100.208:8080/oneportal/login';
  18. //发布地址
  19. // location.href = 'http://dgtcloud.dgtis.com/oneportal/login';
  20. }
  21. }
  22. })
  23. router.afterEach(() => {})