12345678910111213141516171819 |
- import { Injectable } from '@angular/core';
- import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
- import { Observable } from 'rxjs';
- import { NzMessageService } from 'ng-zorro-antd/message';
- @Injectable({
- providedIn: 'root'
- })
- export class AuthGuard implements CanActivate {
- constructor(private message: NzMessageService) { }
- canActivate(
- route: ActivatedRouteSnapshot,
- state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
- // 判断登录逻辑
- this.message.info('判断登录逻辑');
- return true;
- }
- }
|