-
zhangwei
2 天以前 7a8f1cb7741436c43fc5859707da5041d6648953
src/router/index.ts
@@ -106,7 +106,9 @@
}
/** 路由白名单 */
const whiteList = ["/login",'/'];
const whiteList = ["/login"];
const noLoginList = ["/index", "/register", "/registersucess"];
// const whiteList = [];
const { VITE_HIDE_HOME } = import.meta.env;
@@ -135,12 +137,12 @@
  }
  if (Cookies.get(multipleTabsKey) && userInfo) {
    // 无权限跳转403页面
    if (to.meta?.roles && !isOneOfArray(to.meta?.roles, userInfo?.roles)) {
    if (to.meta?.roles && !isOneOfArray(to.meta?.roles, userInfo?.exRoles)) {
      next({ path: "/error/403" });
    }
    // 开启隐藏首页后在浏览器地址栏手动输入首页welcome路由则跳转到404页面
    if (VITE_HIDE_HOME === "true" && to.fullPath === "/welcome") {
      next({ path: "/error/404" });
      next({ path: "/index" });
    }
    if (_from?.name) {
      // name为超链接
@@ -193,10 +195,15 @@
  } else {
    if (to.path !== "/login") {
      if (whiteList.indexOf(to.path) !== -1) {
        console.log(to.path, "====1", noLoginList.indexOf(to.path));
        next();
      } else {
        removeToken();
        next({ path: "/login" });
        // if (noLoginList.indexOf(to.path) == -1) {
        next();
        // } else {
        //   removeToken();
        //   next({ path: "/login" });
        // }
      }
    } else {
      next();