permission.js 820 B

12345678910111213141516171819202122232425
  1. import router from "./router";
  2. import { getCookie, removeToken } from "@/utills/auth"; // getToken from cookie
  3. import { Base64 } from "js-base64";
  4. const whiteList = ["/integratedAlarm", "/login", "/logout"]; // 不重定向白名单
  5. import store from "@/store";
  6. router.beforeEach((to, from, next) => {
  7. if (to.path == "/login" || to.path == "/") {
  8. next({ path: "/integratedAlarm" });
  9. } else {
  10. next();
  11. }
  12. // if (getCookie("authToken")) {
  13. // if (to.path == "/login" || to.path == "/") {
  14. // next({ path: "/integratedAlarm" });
  15. // } else {
  16. // next();
  17. // }
  18. // } else if (whiteList.indexOf(to.path) !== -1) {
  19. // next();
  20. // } else {
  21. // next(`/login?redirect=${to.fullPath}`);
  22. // }
  23. });
  24. router.afterEach((to, from, next) => { });