zhangwei
8 天以前 03c275439949875a857538df89a41696642c42b3
src/router/index.ts
@@ -106,7 +106,15 @@
}
/** 路由白名单 */
const whiteList = ["/login",'/'];
const whiteList = ["/login"];
const noLoginList = [
  "/index",
  "/register",
  "/registernav",
  "/registersucess",
  "/gonggaoDetail"
];
// const whiteList = [];
const { VITE_HIDE_HOME } = import.meta.env;
@@ -126,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;
    });
  }
  /** 如果已经登录并存在登录信息后不能跳转到路由白名单,而是继续保持在当前页面 */
@@ -140,7 +148,7 @@
    }
    // 开启隐藏首页后在浏览器地址栏手动输入首页welcome路由则跳转到404页面
    if (VITE_HIDE_HOME === "true" && to.fullPath === "/welcome") {
      next({ path: "/error/404" });
      next({ path: "/index" });
    }
    if (_from?.name) {
      // name为超链接
@@ -192,11 +200,11 @@
    }
  } else {
    if (to.path !== "/login") {
      if (whiteList.indexOf(to.path) !== -1) {
      if (noLoginList.indexOf(to.path) !== -1) {
        next();
      } else {
        removeToken();
        next({ path: "/login" });
        next({ path: "/index" });
      }
    } else {
      next();