|
@@ -1,68 +1,21 @@
|
|
|
import router from "./router";
|
|
|
import { getCookie,removeToken } from "@/utills/auth"; // getToken from cookie
|
|
|
import { Base64 } from "js-base64";
|
|
|
-const whiteList = ["/login", "/logout"]; // 不重定向白名单
|
|
|
+const whiteList = ["/integratedAlarm", "/login", "/logout"]; // 不重定向白名单
|
|
|
import store from "@/store";
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
- if (getCookie("authToken")) {
|
|
|
- if (to.path == "/login" || to.path == "/") {
|
|
|
- next({ path: "/integratedAlarm" });
|
|
|
- } else {
|
|
|
- next();
|
|
|
- // if (store.getters.roles.length === 0) {
|
|
|
- // // 判断当前用户是否已拉取完user_info信息
|
|
|
- // store
|
|
|
- // .dispatch("user/GetInfo")
|
|
|
- // .then(async () => {
|
|
|
- // let permissions = store.getters.permissions;
|
|
|
- // let accessRoutes = [];
|
|
|
- // accessRoutes = await store.dispatch(
|
|
|
- // "routes/setRoutes",
|
|
|
- // permissions
|
|
|
- // );
|
|
|
- // accessRoutes?.forEach((item) => {
|
|
|
- // router.addRoute(item);
|
|
|
- // });
|
|
|
- // next({ ...to, replace: true });
|
|
|
- // })
|
|
|
- // .catch((err) => {});
|
|
|
- // } else {
|
|
|
- // next();
|
|
|
- // }
|
|
|
- }
|
|
|
- } else if (whiteList.indexOf(to.path) !== -1) {
|
|
|
+ // if (getCookie("authToken")) {
|
|
|
+ // if (to.path == "/login" || to.path == "/") {
|
|
|
+ // next({ path: "/integratedAlarm" });
|
|
|
+ // } else {
|
|
|
+ // next();
|
|
|
+ // }
|
|
|
+ // } else if (whiteList.indexOf(to.path) !== -1) {
|
|
|
+ // next();
|
|
|
+ // } else {
|
|
|
+ // next(`/login?redirect=${to.fullPath}`);
|
|
|
+ // }
|
|
|
next();
|
|
|
- } else {
|
|
|
- next(`/login?redirect=${to.fullPath}`);
|
|
|
- }
|
|
|
-
|
|
|
- //有token或在免登录白名单,直接放行
|
|
|
- // if (getCookie("iamAccessToken")) {
|
|
|
- // if (!store.state.userInfo) {
|
|
|
- // //获取用户资料
|
|
|
- // const result1 = store.dispatch("getUserInfo");
|
|
|
- // //获取菜单
|
|
|
- // const result2 = store.dispatch("getmenuList");
|
|
|
- // next();
|
|
|
- // } else {
|
|
|
- // next();
|
|
|
- // }
|
|
|
- // // next();//放行
|
|
|
- // } else if (whiteList.indexOf(to.path) !== -1) {
|
|
|
- // next(); //放行
|
|
|
- // } else {
|
|
|
- // removeImsCookie();
|
|
|
- // store.state.userInfo = null;
|
|
|
- // const mode = process.env.VUE_APP_LOGIN_MODE;
|
|
|
- // if (mode == 1) {
|
|
|
- // let base64Url = Base64.encode(process.env.VUE_APP_REDIRECT_URL);
|
|
|
- // window.location.href =
|
|
|
- // process.env.VUE_APP_UNIFIED_LOGIN + "&redirect_url=" + base64Url;
|
|
|
- // } else {
|
|
|
- // // router.push('/login');
|
|
|
- // next("/login");
|
|
|
- // }
|
|
|
- // }
|
|
|
});
|
|
|
|
|
|
router.afterEach((to, from, next) => {});
|