@yelon/acl 16.2.4 → 16.2.5-68d194e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +23 -23
- package/esm2022/acl.mjs +4 -4
- package/esm2022/index.mjs +7 -7
- package/esm2022/src/acl-guard.mjs +68 -68
- package/esm2022/src/acl-if.directive.mjs +78 -78
- package/esm2022/src/acl.config.mjs +3 -3
- package/esm2022/src/acl.directive.mjs +47 -47
- package/esm2022/src/acl.module.mjs +27 -27
- package/esm2022/src/acl.service.mjs +194 -194
- package/esm2022/src/acl.type.mjs +6 -6
- package/fesm2022/acl.mjs +417 -417
- package/index.d.ts +7 -7
- package/package.json +45 -45
- package/src/acl-guard.d.ts +51 -51
- package/src/acl-if.directive.d.ts +26 -26
- package/src/acl.config.d.ts +2 -2
- package/src/acl.directive.d.ts +18 -18
- package/src/acl.module.d.ts +11 -11
- package/src/acl.service.d.ts +78 -78
- package/src/acl.type.d.ts +36 -36
- package/src/style/index.less +7 -7
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './src/acl.service';
|
|
2
|
-
export * from './src/acl-if.directive';
|
|
3
|
-
export * from './src/acl.directive';
|
|
4
|
-
export * from './src/acl.config';
|
|
5
|
-
export * from './src/acl.type';
|
|
6
|
-
export * from './src/acl-guard';
|
|
7
|
-
export * from './src/acl.module';
|
|
1
|
+
export * from './src/acl.service';
|
|
2
|
+
export * from './src/acl-if.directive';
|
|
3
|
+
export * from './src/acl.directive';
|
|
4
|
+
export * from './src/acl.config';
|
|
5
|
+
export * from './src/acl.type';
|
|
6
|
+
export * from './src/acl-guard';
|
|
7
|
+
export * from './src/acl.module';
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@yelon/acl",
|
|
3
|
-
"version": "16.2.
|
|
4
|
-
"author": "devcui<devcui@outlook.com>",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/hbyunzai/yelon.git"
|
|
9
|
-
},
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/hbyunzai/ng-yunzai/issues"
|
|
12
|
-
},
|
|
13
|
-
"homepage": "https://ng.yunzainfo.com",
|
|
14
|
-
"keywords": [
|
|
15
|
-
"@yelon/acl",
|
|
16
|
-
"angular acl",
|
|
17
|
-
"ng acl",
|
|
18
|
-
"ngx acl",
|
|
19
|
-
"yelon",
|
|
20
|
-
"ng-yunzai",
|
|
21
|
-
"yunzai",
|
|
22
|
-
"antd",
|
|
23
|
-
"ng-zorro-antd",
|
|
24
|
-
"acl",
|
|
25
|
-
"angular",
|
|
26
|
-
"component"
|
|
27
|
-
],
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@yelon/util": "^16.2.
|
|
30
|
-
"tslib": "^2.3.0"
|
|
31
|
-
},
|
|
32
|
-
"module": "fesm2022/acl.mjs",
|
|
33
|
-
"typings": "index.d.ts",
|
|
34
|
-
"exports": {
|
|
35
|
-
"./package.json": {
|
|
36
|
-
"default": "./package.json"
|
|
37
|
-
},
|
|
38
|
-
".": {
|
|
39
|
-
"types": "./index.d.ts",
|
|
40
|
-
"esm2022": "./esm2022/acl.mjs",
|
|
41
|
-
"esm": "./esm2022/acl.mjs",
|
|
42
|
-
"default": "./fesm2022/acl.mjs"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"sideEffects": false
|
|
1
|
+
{
|
|
2
|
+
"name": "@yelon/acl",
|
|
3
|
+
"version": "16.2.5-68d194e",
|
|
4
|
+
"author": "devcui<devcui@outlook.com>",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/hbyunzai/yelon.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/hbyunzai/ng-yunzai/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://ng.yunzainfo.com",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"@yelon/acl",
|
|
16
|
+
"angular acl",
|
|
17
|
+
"ng acl",
|
|
18
|
+
"ngx acl",
|
|
19
|
+
"yelon",
|
|
20
|
+
"ng-yunzai",
|
|
21
|
+
"yunzai",
|
|
22
|
+
"antd",
|
|
23
|
+
"ng-zorro-antd",
|
|
24
|
+
"acl",
|
|
25
|
+
"angular",
|
|
26
|
+
"component"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@yelon/util": "^16.2.5-68d194e",
|
|
30
|
+
"tslib": "^2.3.0"
|
|
31
|
+
},
|
|
32
|
+
"module": "fesm2022/acl.mjs",
|
|
33
|
+
"typings": "index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
"./package.json": {
|
|
36
|
+
"default": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./index.d.ts",
|
|
40
|
+
"esm2022": "./esm2022/acl.mjs",
|
|
41
|
+
"esm": "./esm2022/acl.mjs",
|
|
42
|
+
"default": "./fesm2022/acl.mjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"sideEffects": false
|
|
46
46
|
}
|
package/src/acl-guard.d.ts
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { Injector } from '@angular/core';
|
|
2
|
-
import { CanActivateChildFn, CanActivateFn, CanMatchFn, Router } from '@angular/router';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
import { ACLService } from './acl.service';
|
|
5
|
-
import type { ACLGuardData } from './acl.type';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
export declare class ACLGuardService {
|
|
8
|
-
private srv;
|
|
9
|
-
private router;
|
|
10
|
-
private injector;
|
|
11
|
-
constructor(srv: ACLService, router: Router, injector: Injector);
|
|
12
|
-
process(data?: ACLGuardData): Observable<boolean>;
|
|
13
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ACLGuardService, never>;
|
|
14
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<ACLGuardService>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* data: {
|
|
21
|
-
* path: 'home',
|
|
22
|
-
* canActivate: [ aclCanActivate ],
|
|
23
|
-
* data: { guard: 'user1' }
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare const aclCanActivate: CanActivateFn;
|
|
28
|
-
/**
|
|
29
|
-
* Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
|
|
30
|
-
*
|
|
31
|
-
* ```ts
|
|
32
|
-
* data: {
|
|
33
|
-
* path: 'home',
|
|
34
|
-
* canActivateChild: [ aclCanActivateChild ],
|
|
35
|
-
* data: { guard: 'user1' }
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare const aclCanActivateChild: CanActivateChildFn;
|
|
40
|
-
/**
|
|
41
|
-
* Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
|
|
42
|
-
*
|
|
43
|
-
* ```ts
|
|
44
|
-
* data: {
|
|
45
|
-
* path: 'home',
|
|
46
|
-
* canMatch: [ aclCanMatch ],
|
|
47
|
-
* data: { guard: 'user1' }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export declare const aclCanMatch: CanMatchFn;
|
|
1
|
+
import { Injector } from '@angular/core';
|
|
2
|
+
import { CanActivateChildFn, CanActivateFn, CanMatchFn, Router } from '@angular/router';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { ACLService } from './acl.service';
|
|
5
|
+
import type { ACLGuardData } from './acl.type';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export declare class ACLGuardService {
|
|
8
|
+
private srv;
|
|
9
|
+
private router;
|
|
10
|
+
private injector;
|
|
11
|
+
constructor(srv: ACLService, router: Router, injector: Injector);
|
|
12
|
+
process(data?: ACLGuardData): Observable<boolean>;
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ACLGuardService, never>;
|
|
14
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ACLGuardService>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* data: {
|
|
21
|
+
* path: 'home',
|
|
22
|
+
* canActivate: [ aclCanActivate ],
|
|
23
|
+
* data: { guard: 'user1' }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const aclCanActivate: CanActivateFn;
|
|
28
|
+
/**
|
|
29
|
+
* Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* data: {
|
|
33
|
+
* path: 'home',
|
|
34
|
+
* canActivateChild: [ aclCanActivateChild ],
|
|
35
|
+
* data: { guard: 'user1' }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const aclCanActivateChild: CanActivateChildFn;
|
|
40
|
+
/**
|
|
41
|
+
* Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* data: {
|
|
45
|
+
* path: 'home',
|
|
46
|
+
* canMatch: [ aclCanMatch ],
|
|
47
|
+
* data: { guard: 'user1' }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const aclCanMatch: CanMatchFn;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
2
|
-
import { ACLService } from './acl.service';
|
|
3
|
-
import { ACLCanType } from './acl.type';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
export declare class ACLIfDirective implements OnDestroy {
|
|
6
|
-
private srv;
|
|
7
|
-
private _viewContainer;
|
|
8
|
-
static ngAcceptInputType_except: boolean | string | undefined | null;
|
|
9
|
-
private _value;
|
|
10
|
-
private _change$;
|
|
11
|
-
private _thenTemplateRef;
|
|
12
|
-
private _elseTemplateRef;
|
|
13
|
-
private _thenViewRef;
|
|
14
|
-
private _elseViewRef;
|
|
15
|
-
private _except;
|
|
16
|
-
constructor(templateRef: TemplateRef<void>, srv: ACLService, _viewContainer: ViewContainerRef);
|
|
17
|
-
set aclIf(value: ACLCanType);
|
|
18
|
-
set aclIfThen(templateRef: TemplateRef<void> | null);
|
|
19
|
-
set aclIfElse(templateRef: TemplateRef<void> | null);
|
|
20
|
-
set except(value: boolean);
|
|
21
|
-
get except(): boolean;
|
|
22
|
-
protected _updateView(): void;
|
|
23
|
-
ngOnDestroy(): void;
|
|
24
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ACLIfDirective, never>;
|
|
25
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<ACLIfDirective, "[aclIf]", ["aclIf"], { "aclIf": { "alias": "aclIf"; "required": false; }; "aclIfThen": { "alias": "aclIfThen"; "required": false; }; "aclIfElse": { "alias": "aclIfElse"; "required": false; }; "except": { "alias": "except"; "required": false; }; }, {}, never, never, false, never>;
|
|
26
|
-
}
|
|
1
|
+
import { OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
2
|
+
import { ACLService } from './acl.service';
|
|
3
|
+
import { ACLCanType } from './acl.type';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class ACLIfDirective implements OnDestroy {
|
|
6
|
+
private srv;
|
|
7
|
+
private _viewContainer;
|
|
8
|
+
static ngAcceptInputType_except: boolean | string | undefined | null;
|
|
9
|
+
private _value;
|
|
10
|
+
private _change$;
|
|
11
|
+
private _thenTemplateRef;
|
|
12
|
+
private _elseTemplateRef;
|
|
13
|
+
private _thenViewRef;
|
|
14
|
+
private _elseViewRef;
|
|
15
|
+
private _except;
|
|
16
|
+
constructor(templateRef: TemplateRef<void>, srv: ACLService, _viewContainer: ViewContainerRef);
|
|
17
|
+
set aclIf(value: ACLCanType);
|
|
18
|
+
set aclIfThen(templateRef: TemplateRef<void> | null);
|
|
19
|
+
set aclIfElse(templateRef: TemplateRef<void> | null);
|
|
20
|
+
set except(value: boolean);
|
|
21
|
+
get except(): boolean;
|
|
22
|
+
protected _updateView(): void;
|
|
23
|
+
ngOnDestroy(): void;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ACLIfDirective, never>;
|
|
25
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ACLIfDirective, "[aclIf]", ["aclIf"], { "aclIf": { "alias": "aclIf"; "required": false; }; "aclIfThen": { "alias": "aclIfThen"; "required": false; }; "aclIfElse": { "alias": "aclIfElse"; "required": false; }; "except": { "alias": "except"; "required": false; }; }, {}, never, never, false, never>;
|
|
26
|
+
}
|
package/src/acl.config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { YunzaiACLConfig } from '@yelon/util/config';
|
|
2
|
-
export declare const ACL_DEFAULT_CONFIG: YunzaiACLConfig;
|
|
1
|
+
import type { YunzaiACLConfig } from '@yelon/util/config';
|
|
2
|
+
export declare const ACL_DEFAULT_CONFIG: YunzaiACLConfig;
|
package/src/acl.directive.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ElementRef, OnDestroy, Renderer2 } from '@angular/core';
|
|
2
|
-
import { ACLService } from './acl.service';
|
|
3
|
-
import { ACLCanType } from './acl.type';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
export declare class ACLDirective implements OnDestroy {
|
|
6
|
-
private el;
|
|
7
|
-
private renderer;
|
|
8
|
-
protected srv: ACLService;
|
|
9
|
-
private _value;
|
|
10
|
-
private change$;
|
|
11
|
-
set acl(value: ACLCanType);
|
|
12
|
-
set ability(value: ACLCanType);
|
|
13
|
-
private set;
|
|
14
|
-
constructor(el: ElementRef, renderer: Renderer2, srv: ACLService);
|
|
15
|
-
ngOnDestroy(): void;
|
|
16
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ACLDirective, never>;
|
|
17
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<ACLDirective, "[acl]", ["acl"], { "acl": { "alias": "acl"; "required": false; }; "ability": { "alias": "acl-ability"; "required": false; }; }, {}, never, never, false, never>;
|
|
18
|
-
}
|
|
1
|
+
import { ElementRef, OnDestroy, Renderer2 } from '@angular/core';
|
|
2
|
+
import { ACLService } from './acl.service';
|
|
3
|
+
import { ACLCanType } from './acl.type';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class ACLDirective implements OnDestroy {
|
|
6
|
+
private el;
|
|
7
|
+
private renderer;
|
|
8
|
+
protected srv: ACLService;
|
|
9
|
+
private _value;
|
|
10
|
+
private change$;
|
|
11
|
+
set acl(value: ACLCanType);
|
|
12
|
+
set ability(value: ACLCanType);
|
|
13
|
+
private set;
|
|
14
|
+
constructor(el: ElementRef, renderer: Renderer2, srv: ACLService);
|
|
15
|
+
ngOnDestroy(): void;
|
|
16
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ACLDirective, never>;
|
|
17
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ACLDirective, "[acl]", ["acl"], { "acl": { "alias": "acl"; "required": false; }; "ability": { "alias": "acl-ability"; "required": false; }; }, {}, never, never, false, never>;
|
|
18
|
+
}
|
package/src/acl.module.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
import * as i1 from "./acl.directive";
|
|
4
|
-
import * as i2 from "./acl-if.directive";
|
|
5
|
-
import * as i3 from "@angular/common";
|
|
6
|
-
export declare class YelonACLModule {
|
|
7
|
-
static forRoot(): ModuleWithProviders<YelonACLModule>;
|
|
8
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<YelonACLModule, never>;
|
|
9
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<YelonACLModule, [typeof i1.ACLDirective, typeof i2.ACLIfDirective], [typeof i3.CommonModule], [typeof i1.ACLDirective, typeof i2.ACLIfDirective]>;
|
|
10
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<YelonACLModule>;
|
|
11
|
-
}
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import * as i1 from "./acl.directive";
|
|
4
|
+
import * as i2 from "./acl-if.directive";
|
|
5
|
+
import * as i3 from "@angular/common";
|
|
6
|
+
export declare class YelonACLModule {
|
|
7
|
+
static forRoot(): ModuleWithProviders<YelonACLModule>;
|
|
8
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<YelonACLModule, never>;
|
|
9
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<YelonACLModule, [typeof i1.ACLDirective, typeof i2.ACLIfDirective], [typeof i3.CommonModule], [typeof i1.ACLDirective, typeof i2.ACLIfDirective]>;
|
|
10
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<YelonACLModule>;
|
|
11
|
+
}
|
package/src/acl.service.d.ts
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { YunzaiConfigService } from '@yelon/util/config';
|
|
3
|
-
import { ACLCanType, ACLType } from './acl.type';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
/**
|
|
6
|
-
* ACL 控制服务,[在线文档](https://ng.yunzainfo.com/acl)
|
|
7
|
-
*
|
|
8
|
-
* 务必在根目录注册 `YelonACLModule.forRoot()` 才能使用服务
|
|
9
|
-
*/
|
|
10
|
-
export declare class ACLService {
|
|
11
|
-
private options;
|
|
12
|
-
private roles;
|
|
13
|
-
private abilities;
|
|
14
|
-
private full;
|
|
15
|
-
private aclChange;
|
|
16
|
-
/** ACL变更通知 */
|
|
17
|
-
get change(): Observable<ACLType | boolean | null>;
|
|
18
|
-
/** 获取所有数据 */
|
|
19
|
-
get data(): {
|
|
20
|
-
full: boolean;
|
|
21
|
-
roles: string[];
|
|
22
|
-
abilities: Array<string | number>;
|
|
23
|
-
};
|
|
24
|
-
get guard_url(): string;
|
|
25
|
-
constructor(configSrv: YunzaiConfigService);
|
|
26
|
-
private parseACLType;
|
|
27
|
-
/**
|
|
28
|
-
* 设置当前用户角色或权限能力(会先清除所有)
|
|
29
|
-
*/
|
|
30
|
-
set(value: ACLType): void;
|
|
31
|
-
/**
|
|
32
|
-
* 标识当前用户为全量,即不受限
|
|
33
|
-
*/
|
|
34
|
-
setFull(val: boolean): void;
|
|
35
|
-
/**
|
|
36
|
-
* 设置当前用户权限能力(会先清除所有)
|
|
37
|
-
*/
|
|
38
|
-
setAbility(abilities: Array<number | string>): void;
|
|
39
|
-
/**
|
|
40
|
-
* 设置当前用户角色(会先清除所有)
|
|
41
|
-
*/
|
|
42
|
-
setRole(roles: string[]): void;
|
|
43
|
-
/**
|
|
44
|
-
* 为当前用户增加角色或权限能力
|
|
45
|
-
*/
|
|
46
|
-
add(value: ACLType): void;
|
|
47
|
-
/**
|
|
48
|
-
* 为当前用户附加角色
|
|
49
|
-
*/
|
|
50
|
-
attachRole(roles: string[]): void;
|
|
51
|
-
/**
|
|
52
|
-
* 为当前用户附加权限
|
|
53
|
-
*/
|
|
54
|
-
attachAbility(abilities: Array<number | string>): void;
|
|
55
|
-
/**
|
|
56
|
-
* 为当前用户移除角色
|
|
57
|
-
*/
|
|
58
|
-
removeRole(roles: string[]): void;
|
|
59
|
-
/**
|
|
60
|
-
* 为当前用户移除权限
|
|
61
|
-
*/
|
|
62
|
-
removeAbility(abilities: Array<number | string>): void;
|
|
63
|
-
/**
|
|
64
|
-
* 当前用户是否有对应角色,其实 `number` 表示Ability
|
|
65
|
-
*
|
|
66
|
-
* - 当 `full: true` 或参数 `null` 时返回 `true`
|
|
67
|
-
* - 若使用 `ACLType` 参数,可以指定 `mode` 校验模式
|
|
68
|
-
*/
|
|
69
|
-
can(roleOrAbility: ACLCanType | null): boolean;
|
|
70
|
-
/** @inner */
|
|
71
|
-
parseAbility(value: ACLCanType): ACLCanType;
|
|
72
|
-
/**
|
|
73
|
-
* 当前用户是否有对应权限点
|
|
74
|
-
*/
|
|
75
|
-
canAbility(value: ACLCanType): boolean;
|
|
76
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ACLService, never>;
|
|
77
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<ACLService>;
|
|
78
|
-
}
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { YunzaiConfigService } from '@yelon/util/config';
|
|
3
|
+
import { ACLCanType, ACLType } from './acl.type';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* ACL 控制服务,[在线文档](https://ng.yunzainfo.com/acl)
|
|
7
|
+
*
|
|
8
|
+
* 务必在根目录注册 `YelonACLModule.forRoot()` 才能使用服务
|
|
9
|
+
*/
|
|
10
|
+
export declare class ACLService {
|
|
11
|
+
private options;
|
|
12
|
+
private roles;
|
|
13
|
+
private abilities;
|
|
14
|
+
private full;
|
|
15
|
+
private aclChange;
|
|
16
|
+
/** ACL变更通知 */
|
|
17
|
+
get change(): Observable<ACLType | boolean | null>;
|
|
18
|
+
/** 获取所有数据 */
|
|
19
|
+
get data(): {
|
|
20
|
+
full: boolean;
|
|
21
|
+
roles: string[];
|
|
22
|
+
abilities: Array<string | number>;
|
|
23
|
+
};
|
|
24
|
+
get guard_url(): string;
|
|
25
|
+
constructor(configSrv: YunzaiConfigService);
|
|
26
|
+
private parseACLType;
|
|
27
|
+
/**
|
|
28
|
+
* 设置当前用户角色或权限能力(会先清除所有)
|
|
29
|
+
*/
|
|
30
|
+
set(value: ACLType): void;
|
|
31
|
+
/**
|
|
32
|
+
* 标识当前用户为全量,即不受限
|
|
33
|
+
*/
|
|
34
|
+
setFull(val: boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* 设置当前用户权限能力(会先清除所有)
|
|
37
|
+
*/
|
|
38
|
+
setAbility(abilities: Array<number | string>): void;
|
|
39
|
+
/**
|
|
40
|
+
* 设置当前用户角色(会先清除所有)
|
|
41
|
+
*/
|
|
42
|
+
setRole(roles: string[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* 为当前用户增加角色或权限能力
|
|
45
|
+
*/
|
|
46
|
+
add(value: ACLType): void;
|
|
47
|
+
/**
|
|
48
|
+
* 为当前用户附加角色
|
|
49
|
+
*/
|
|
50
|
+
attachRole(roles: string[]): void;
|
|
51
|
+
/**
|
|
52
|
+
* 为当前用户附加权限
|
|
53
|
+
*/
|
|
54
|
+
attachAbility(abilities: Array<number | string>): void;
|
|
55
|
+
/**
|
|
56
|
+
* 为当前用户移除角色
|
|
57
|
+
*/
|
|
58
|
+
removeRole(roles: string[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* 为当前用户移除权限
|
|
61
|
+
*/
|
|
62
|
+
removeAbility(abilities: Array<number | string>): void;
|
|
63
|
+
/**
|
|
64
|
+
* 当前用户是否有对应角色,其实 `number` 表示Ability
|
|
65
|
+
*
|
|
66
|
+
* - 当 `full: true` 或参数 `null` 时返回 `true`
|
|
67
|
+
* - 若使用 `ACLType` 参数,可以指定 `mode` 校验模式
|
|
68
|
+
*/
|
|
69
|
+
can(roleOrAbility: ACLCanType | null): boolean;
|
|
70
|
+
/** @inner */
|
|
71
|
+
parseAbility(value: ACLCanType): ACLCanType;
|
|
72
|
+
/**
|
|
73
|
+
* 当前用户是否有对应权限点
|
|
74
|
+
*/
|
|
75
|
+
canAbility(value: ACLCanType): boolean;
|
|
76
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ACLService, never>;
|
|
77
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ACLService>;
|
|
78
|
+
}
|
package/src/acl.type.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NOTE:`ACLType` 类型可能会被其他类库所引用,为了减少类库间彼此的依赖性,其他类库会以复制的形式存在
|
|
3
|
-
* 当这里有变化时,请务必同步更新,涉及:`MenuService.acl`、`util.YunzaiACLType`
|
|
4
|
-
* TODO: 尝试增加 `@yelon/core` 类库用于处理这种通用型
|
|
5
|
-
*/
|
|
6
|
-
import { Injector } from '@angular/core';
|
|
7
|
-
import { Observable } from 'rxjs';
|
|
8
|
-
import type { ACLService } from './acl.service';
|
|
9
|
-
export interface ACLType {
|
|
10
|
-
/**
|
|
11
|
-
* 角色
|
|
12
|
-
*/
|
|
13
|
-
role?: string[];
|
|
14
|
-
/**
|
|
15
|
-
* 权限点
|
|
16
|
-
*/
|
|
17
|
-
ability?: number[] | string[];
|
|
18
|
-
/**
|
|
19
|
-
* Validated against, default: `oneOf`
|
|
20
|
-
* - `allOf` the value validates against all the roles or abilities
|
|
21
|
-
* - `oneOf` the value validates against exactly one of the roles or abilities
|
|
22
|
-
*/
|
|
23
|
-
mode?: 'allOf' | 'oneOf';
|
|
24
|
-
/**
|
|
25
|
-
* 是否取反,即结果为 `true` 时表示未授权
|
|
26
|
-
*/
|
|
27
|
-
except?: boolean;
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
}
|
|
30
|
-
export type ACLCanType = number | number[] | string | string[] | ACLType;
|
|
31
|
-
export type ACLGuardFunctionType = (srv: ACLService, injector: Injector) => Observable<ACLCanType>;
|
|
32
|
-
export type ACLGuardType = ACLCanType | Observable<ACLCanType> | ACLGuardFunctionType;
|
|
33
|
-
export interface ACLGuardData {
|
|
34
|
-
guard?: ACLGuardType | null;
|
|
35
|
-
guard_url?: string | null;
|
|
36
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* NOTE:`ACLType` 类型可能会被其他类库所引用,为了减少类库间彼此的依赖性,其他类库会以复制的形式存在
|
|
3
|
+
* 当这里有变化时,请务必同步更新,涉及:`MenuService.acl`、`util.YunzaiACLType`
|
|
4
|
+
* TODO: 尝试增加 `@yelon/core` 类库用于处理这种通用型
|
|
5
|
+
*/
|
|
6
|
+
import { Injector } from '@angular/core';
|
|
7
|
+
import { Observable } from 'rxjs';
|
|
8
|
+
import type { ACLService } from './acl.service';
|
|
9
|
+
export interface ACLType {
|
|
10
|
+
/**
|
|
11
|
+
* 角色
|
|
12
|
+
*/
|
|
13
|
+
role?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* 权限点
|
|
16
|
+
*/
|
|
17
|
+
ability?: number[] | string[];
|
|
18
|
+
/**
|
|
19
|
+
* Validated against, default: `oneOf`
|
|
20
|
+
* - `allOf` the value validates against all the roles or abilities
|
|
21
|
+
* - `oneOf` the value validates against exactly one of the roles or abilities
|
|
22
|
+
*/
|
|
23
|
+
mode?: 'allOf' | 'oneOf';
|
|
24
|
+
/**
|
|
25
|
+
* 是否取反,即结果为 `true` 时表示未授权
|
|
26
|
+
*/
|
|
27
|
+
except?: boolean;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}
|
|
30
|
+
export type ACLCanType = number | number[] | string | string[] | ACLType;
|
|
31
|
+
export type ACLGuardFunctionType = (srv: ACLService, injector: Injector) => Observable<ACLCanType>;
|
|
32
|
+
export type ACLGuardType = ACLCanType | Observable<ACLCanType> | ACLGuardFunctionType;
|
|
33
|
+
export interface ACLGuardData {
|
|
34
|
+
guard?: ACLGuardType | null;
|
|
35
|
+
guard_url?: string | null;
|
|
36
|
+
}
|
package/src/style/index.less
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* [ACL](https://ng.yunzainfo.com/acl/control) 使用 `display: none` 隐藏未授权元素
|
|
3
|
-
* [ACL](https://ng.yunzainfo.com/acl/control) Hides the unauthorized element with `display: none`
|
|
4
|
-
*/
|
|
5
|
-
.acl__hide {
|
|
6
|
-
display: none !important;
|
|
7
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* [ACL](https://ng.yunzainfo.com/acl/control) 使用 `display: none` 隐藏未授权元素
|
|
3
|
+
* [ACL](https://ng.yunzainfo.com/acl/control) Hides the unauthorized element with `display: none`
|
|
4
|
+
*/
|
|
5
|
+
.acl__hide {
|
|
6
|
+
display: none !important;
|
|
7
|
+
}
|