import { CanActivateFn } from '@angular/router';

export const authLocalGuard: CanActivateFn = (route, state) => {
  // 检查当前本地存储中，是否有用户验证信息
  let userAuth = localStorage.getItem("USER_AUTH")
  if (userAuth) {
    return true;
  } else {
    // 暂时存储登陆前用户所在页面
    let REDIRECT_URL = location.pathname;
    localStorage.setItem("REDIRECT_URL", REDIRECT_URL);
    location.href = "/user/login"
    return false;
  }
};
