zhangwei
8 天以前 03c275439949875a857538df89a41696642c42b3
src/router/index.ts
@@ -107,7 +107,13 @@
/** 路由白名单 */
const whiteList = ["/login"];
const noLoginList = ["/index", "/register", "/registersucess"];
const noLoginList = [
  "/index",
  "/register",
  "/registernav",
  "/registersucess",
  "/gonggaoDetail"
];
// const whiteList = [];
const { VITE_HIDE_HOME } = import.meta.env;
@@ -128,7 +134,7 @@
      if (!item.meta.title) return "";
      const Title = getConfig().Title;
      if (Title) document.title = `${item.meta.title} | ${Title}`;
      else document.title = item.meta.title as string;
      else document.title = item.meta.title;
    });
  }
  /** 如果已经登录并存在登录信息后不能跳转到路由白名单,而是继续保持在当前页面 */
@@ -137,7 +143,7 @@
  }
  if (Cookies.get(multipleTabsKey) && userInfo) {
    // 无权限跳转403页面
    if (to.meta?.roles && !isOneOfArray(to.meta?.roles, userInfo?.exRoles)) {
    if (to.meta?.roles && !isOneOfArray(to.meta?.roles, userInfo?.roles)) {
      next({ path: "/error/403" });
    }
    // 开启隐藏首页后在浏览器地址栏手动输入首页welcome路由则跳转到404页面
@@ -194,15 +200,11 @@
    }
  } else {
    if (to.path !== "/login") {
      if (whiteList.indexOf(to.path) !== -1) {
      if (noLoginList.indexOf(to.path) !== -1) {
        next();
      } else {
        // if (noLoginList.indexOf(to.path) == -1) {
        next();
        // } else {
        //   removeToken();
        //   next({ path: "/login" });
        // }
        removeToken();
        next({ path: "/index" });
      }
    } else {
      next();