解决冲突
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* @Description :
|
||||
* @Description :
|
||||
* @Version : 1.0
|
||||
* @Author : Shiming
|
||||
* @Date : 2022-01-25 16:03:45
|
||||
* @LastEditors : Shiming
|
||||
* @LastEditTime : 2022-01-26 18:04:46
|
||||
* @LastEditTime : 2022-02-09 17:23:22
|
||||
* @FilePath : \\tms-obc-web\\src\\app\\core\\guards\\auth.guard.ts
|
||||
* Copyright (C) 2022 huzhenhong. All rights reserved.
|
||||
*/
|
||||
@ -28,46 +28,56 @@ import { Observable, of } from 'rxjs';
|
||||
import { delay, map, switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
export class AuthGuard extends ACLGuard {
|
||||
constructor(
|
||||
private srv: ACLService,
|
||||
srv: ACLService,
|
||||
public srv1: ACLService,
|
||||
private baseService: BaseService,
|
||||
private menuService: MenuService,
|
||||
private router: Router,
|
||||
private injector: Injector
|
||||
) {}
|
||||
router: Router,
|
||||
private inject: Injector
|
||||
) {
|
||||
super(srv, router, inject);
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot | null): Observable<boolean> {
|
||||
canActivate(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot): Observable<boolean> {
|
||||
if (Object.keys(route.params)?.length > 0 || !route.routeConfig?.path) {
|
||||
return this.handle();
|
||||
return this.handle(route, _state, 1);
|
||||
} else {
|
||||
return this.handle(_state?.url);
|
||||
return this.handle(route, _state, 1, _state?.url);
|
||||
}
|
||||
}
|
||||
|
||||
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
||||
return this.handle(this.settingRoute(childRoute.params, state.url));
|
||||
return this.handle(childRoute, state, 2, this.settingRoute(childRoute.params, state.url));
|
||||
}
|
||||
|
||||
private handle(route?: string): Observable<boolean> {
|
||||
if (!route) {
|
||||
return of(true);
|
||||
private handle(route: ActivatedRouteSnapshot, state: RouterStateSnapshot, type: 1 | 2, router?: string): Observable<boolean> {
|
||||
if (!router) {
|
||||
if (type === 1) {
|
||||
return super.canActivate(route, state);
|
||||
} else {
|
||||
return super.canActivateChild(route, state);
|
||||
}
|
||||
}
|
||||
return this.baseService.request('/api/mdc/cuc/functionButton/getUserFunctionButton', { link: route }).pipe(
|
||||
// console.log(route, state, type, router);
|
||||
|
||||
return this.baseService.request('/api/mdc/cuc/functionButton/getUserFunctionButton', { link: router }).pipe(
|
||||
switchMap(res => {
|
||||
if (res) {
|
||||
console.log('666')
|
||||
console.log(res)
|
||||
// this.srv.setAbility(res.abilities || []);
|
||||
// this.menuService.resume();
|
||||
this.baseService.request('/api/mdc/cuc/enterpriseProject/getUserDefaultEnterpriseProject').subscribe((res: any) => {
|
||||
if(!res.enterpriseIdentity){
|
||||
this.srv.setAbility(res.abilities || []);
|
||||
this.menuService.resume();
|
||||
}
|
||||
})
|
||||
// if (router === '/ticket/invoice-requested') {
|
||||
// this.srv1.setAbility(['TICKET-INVOICE-REQUESTED-list']);
|
||||
// } else {
|
||||
// this.srv1.setAbility(res.abilities || []);
|
||||
// }
|
||||
this.srv1.setAbility(res.abilities || []);
|
||||
this.menuService.resume();
|
||||
}
|
||||
if (type === 1) {
|
||||
return super.canActivate(route, state);
|
||||
} else {
|
||||
return super.canActivateChild(route, state);
|
||||
}
|
||||
return of(true);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user