auth.guard.ts 637 B

12345678910111213141516171819
  1. import { Injectable } from '@angular/core';
  2. import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
  3. import { Observable } from 'rxjs';
  4. import { NzMessageService } from 'ng-zorro-antd/message';
  5. @Injectable({
  6. providedIn: 'root'
  7. })
  8. export class AuthGuard implements CanActivate {
  9. constructor(private message: NzMessageService) { }
  10. canActivate(
  11. route: ActivatedRouteSnapshot,
  12. state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
  13. // 判断登录逻辑
  14. this.message.info('判断登录逻辑');
  15. return true;
  16. }
  17. }