zhangwei
2025-08-27 f0c7f4845fb40bb75b2c9eb61a790e9b8ea7401a
src/router/index.ts
@@ -106,7 +106,9 @@
}
/** 路由白名单 */
const whiteList = [];
const whiteList = ["/login"];
const noLoginList = ["/index", "/register", "/registernav", "/registersucess"];
// const whiteList = [];
const { VITE_HIDE_HOME } = import.meta.env;
@@ -126,7 +128,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 +142,7 @@
    }
    // 开启隐藏首页后在浏览器地址栏手动输入首页welcome路由则跳转到404页面
    if (VITE_HIDE_HOME === "true" && to.fullPath === "/welcome") {
      next({ path: "/error/404" });
      next({ path: "/index" });
    }
    if (_from?.name) {
      // name为超链接
@@ -192,11 +194,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();