1234567891011121314151617181920212223 |
- import { Injectable } from '@angular/core';
- import { CanActivate, Router } from '@angular/router';
- @Injectable({
- providedIn: 'root'
- })
- export class DataGenerateGuard implements CanActivate {
- constructor(public router: Router) { }
- canActivate(): boolean {
- const menus = JSON.parse(localStorage.getItem('menu'));
- let can = false;
- if (menus) {
- can = menus.some(e => e.link == 'dataGenerate');
- }
- if (!can) {
- this.router.navigate(['login']);
- return false
- }
- return true;
- }
- }
|