/** 跳转到登录页 */
export const toLoginPage = (callbackUrl: boolean | string = true): void => {
  if (typeof callbackUrl === "boolean" && callbackUrl) {
    // 如果是 true 就是用当前 url 作为登录成功后回调地址
    callbackUrl = encodeURIComponent(window.location.href);
  }

  const queryStr = callbackUrl ? `?callbackUrl=${callbackUrl}` : "";

  if (process.env.NODE_ENV === "production") {
    let loginUrl = `https://xxyy.co/#/login${queryStr}`;
    // 测试环境
    if (window.location.host.endsWith(".kube.ucas")) {
      loginUrl = `https://test-www.kube.ucas/login${queryStr}`;
    }
    window.location.href = loginUrl;
  } else {
    window.location.href = `/saturn/login${queryStr}`;
  }
};
