com-angel-authorization 1.0.11 → 1.0.15
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/README.md +52 -3
- package/dist/index.cjs +131 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -5
- package/dist/index.d.ts +74 -5
- package/dist/index.js +124 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +879 -20
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +88 -10
- package/dist/react/index.d.ts +88 -10
- package/dist/react/index.js +874 -19
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.cjs +1026 -26
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +129 -16
- package/dist/vue/index.d.ts +129 -16
- package/dist/vue/index.js +1022 -24
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/vue/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { InjectionKey, ComputedRef, Plugin, Directive, PropType } from 'vue';
|
|
2
|
+
import { InjectionKey, ComputedRef, Plugin, Directive, PropType, VNode } from 'vue';
|
|
3
3
|
|
|
4
4
|
type PermissionCode = string;
|
|
5
5
|
type RoleCode = string;
|
|
@@ -26,12 +26,25 @@ interface PermissionChecker {
|
|
|
26
26
|
can(codes: PermissionCode | PermissionCode[], options?: CheckOptions): boolean;
|
|
27
27
|
getState(): PermissionState;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 权限 store 的公共接口(不含 class private 字段)。
|
|
31
|
+
* 用于跨入口(主包 / react / vue)传参,避免重复打包后的名义类型冲突。
|
|
32
|
+
*/
|
|
33
|
+
interface PermissionStoreAPI extends PermissionChecker {
|
|
34
|
+
setState(next: Partial<PermissionState>): void;
|
|
35
|
+
setPermissions(permissions: PermissionCode[]): void;
|
|
36
|
+
setRoles(roles: RoleCode[]): void;
|
|
37
|
+
setSuperAdmin(isSuperAdmin: boolean): void;
|
|
38
|
+
hydrate(payload: Partial<PermissionState>): void;
|
|
39
|
+
clear(): void;
|
|
40
|
+
subscribe(listener: PermissionListener): () => void;
|
|
41
|
+
}
|
|
29
42
|
|
|
30
43
|
/**
|
|
31
44
|
* Mutable permission store shared by React / Vue adapters.
|
|
32
45
|
* Framework-agnostic — safe to use in Node, browser, or any UI lib.
|
|
33
46
|
*/
|
|
34
|
-
declare class PermissionStore implements
|
|
47
|
+
declare class PermissionStore implements PermissionStoreAPI {
|
|
35
48
|
private state;
|
|
36
49
|
private permissionSet;
|
|
37
50
|
private roleSet;
|
|
@@ -53,19 +66,19 @@ declare class PermissionStore implements PermissionChecker {
|
|
|
53
66
|
subscribe(listener: PermissionListener): () => void;
|
|
54
67
|
private emit;
|
|
55
68
|
}
|
|
56
|
-
declare function createPermissionStore(initial?: Partial<PermissionState>):
|
|
69
|
+
declare function createPermissionStore(initial?: Partial<PermissionState>): PermissionStoreAPI;
|
|
57
70
|
|
|
58
|
-
declare const PERMISSION_STORE_KEY: InjectionKey<
|
|
71
|
+
declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStoreAPI>;
|
|
59
72
|
interface PermissionPluginOptions {
|
|
60
73
|
/** Pass an existing store to share across apps. */
|
|
61
|
-
store?:
|
|
74
|
+
store?: PermissionStoreAPI;
|
|
62
75
|
/** Initial state when the plugin creates its own store. */
|
|
63
76
|
initialState?: Partial<PermissionState>;
|
|
64
77
|
/** Custom directive name. Default: `permission` → `v-permission`. */
|
|
65
78
|
directiveName?: string;
|
|
66
79
|
}
|
|
67
80
|
declare function createPermissionPlugin(options?: PermissionPluginOptions): Plugin & {
|
|
68
|
-
store:
|
|
81
|
+
store: PermissionStoreAPI;
|
|
69
82
|
};
|
|
70
83
|
interface UsePermissionResult {
|
|
71
84
|
permissions: ComputedRef<PermissionCode[]>;
|
|
@@ -79,17 +92,17 @@ interface UsePermissionResult {
|
|
|
79
92
|
setSuperAdmin: (isSuperAdmin: boolean) => void;
|
|
80
93
|
hydrate: (payload: Partial<PermissionState>) => void;
|
|
81
94
|
clear: () => void;
|
|
82
|
-
store:
|
|
95
|
+
store: PermissionStoreAPI;
|
|
83
96
|
}
|
|
84
97
|
/**
|
|
85
98
|
* Reactive permission API for Vue 3 Composition API.
|
|
86
99
|
*/
|
|
87
|
-
declare function usePermission(store?:
|
|
88
|
-
declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?:
|
|
89
|
-
declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?:
|
|
100
|
+
declare function usePermission(store?: PermissionStoreAPI): UsePermissionResult;
|
|
101
|
+
declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?: PermissionStoreAPI): ComputedRef<boolean>;
|
|
102
|
+
declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?: PermissionStoreAPI): ComputedRef<boolean>;
|
|
90
103
|
declare module 'vue' {
|
|
91
104
|
interface ComponentCustomProperties {
|
|
92
|
-
$permission:
|
|
105
|
+
$permission: PermissionStoreAPI;
|
|
93
106
|
$can: (codes: PermissionCode | PermissionCode[], options?: CheckOptions) => boolean;
|
|
94
107
|
$hasRole: (codes: RoleCode | RoleCode[], options?: CheckOptions) => boolean;
|
|
95
108
|
}
|
|
@@ -112,7 +125,7 @@ type ElWithPermission = HTMLElement & {
|
|
|
112
125
|
* Create a `v-permission` directive bound to a specific store.
|
|
113
126
|
* Prefer installing via `createPermissionPlugin()` which registers this automatically.
|
|
114
127
|
*/
|
|
115
|
-
declare function createVPermission(store:
|
|
128
|
+
declare function createVPermission(store: PermissionStoreAPI): Directive<ElWithPermission, PermissionDirectiveValue>;
|
|
116
129
|
|
|
117
130
|
/**
|
|
118
131
|
* Conditionally render slot content based on permission / role.
|
|
@@ -435,7 +448,99 @@ declare const MenuManager: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
435
448
|
pageSize: string;
|
|
436
449
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
437
450
|
|
|
438
|
-
type
|
|
451
|
+
type SystemRole = {
|
|
452
|
+
roleId: string;
|
|
453
|
+
name: string;
|
|
454
|
+
description: string;
|
|
455
|
+
};
|
|
456
|
+
type SystemRoleFormValues = {
|
|
457
|
+
name: string;
|
|
458
|
+
description: string;
|
|
459
|
+
};
|
|
460
|
+
type CreateSystemRoleBody = SystemRoleFormValues;
|
|
461
|
+
type UpdateSystemRoleBody = Partial<SystemRoleFormValues>;
|
|
462
|
+
type FetchSystemRolesParams = {
|
|
463
|
+
keyword?: string;
|
|
464
|
+
pagination?: ListPaginationParams;
|
|
465
|
+
};
|
|
466
|
+
type SystemRoleListResult = {
|
|
467
|
+
records: SystemRole[];
|
|
468
|
+
pageToken: string;
|
|
469
|
+
hasPreviousPage: boolean;
|
|
470
|
+
hasNextPage: boolean;
|
|
471
|
+
};
|
|
472
|
+
/** 角色授权树节点 */
|
|
473
|
+
type RolePermissionTreeNode = {
|
|
474
|
+
resourceId: string;
|
|
475
|
+
name: string;
|
|
476
|
+
children: RolePermissionTreeNode[];
|
|
477
|
+
};
|
|
478
|
+
/** GET /system/roles/{role-id}/permissions */
|
|
479
|
+
type RolePermissionsResult = {
|
|
480
|
+
/** 当前角色已授予的资源 ID,用于树回显勾选 */
|
|
481
|
+
resourceIds: string[];
|
|
482
|
+
resourceTree: RolePermissionTreeNode[];
|
|
483
|
+
};
|
|
484
|
+
/** POST /system/roles/{role-id}/permissions */
|
|
485
|
+
type SaveRolePermissionsBody = {
|
|
486
|
+
resourceIds: string[];
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
type SystemRoleApi = {
|
|
490
|
+
list: (params?: FetchSystemRolesParams, signal?: AbortSignal) => Promise<SystemRoleListResult>;
|
|
491
|
+
create: (values: SystemRoleFormValues, signal?: AbortSignal) => Promise<unknown>;
|
|
492
|
+
update: (roleId: string, values: SystemRoleFormValues, signal?: AbortSignal) => Promise<unknown>;
|
|
493
|
+
remove: (roleId: string, signal?: AbortSignal) => Promise<unknown>;
|
|
494
|
+
getPermissions: (roleId: string, signal?: AbortSignal) => Promise<RolePermissionsResult>;
|
|
495
|
+
savePermissions: (roleId: string, resourceIds: string[], signal?: AbortSignal) => Promise<unknown>;
|
|
496
|
+
};
|
|
497
|
+
declare function mapSystemRole(item: unknown): SystemRole | null;
|
|
498
|
+
declare function mapPermissionTreeNode(item: unknown): RolePermissionTreeNode | null;
|
|
499
|
+
declare function mapRolePermissions(payload: unknown): RolePermissionsResult;
|
|
500
|
+
/** 收集节点及其全部子孙 resourceId */
|
|
501
|
+
declare function collectTreeResourceIds(node: RolePermissionTreeNode): string[];
|
|
502
|
+
declare function buildCreateRoleBody(values: SystemRoleFormValues): CreateSystemRoleBody;
|
|
503
|
+
declare function buildUpdateRoleBody(values: SystemRoleFormValues): UpdateSystemRoleBody;
|
|
504
|
+
declare function buildSavePermissionsBody(resourceIds: string[]): SaveRolePermissionsBody;
|
|
505
|
+
declare function createSystemRoleApi(request: ResourceHttpRequest): SystemRoleApi;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* 角色管理页面(Vue 3)
|
|
509
|
+
*/
|
|
510
|
+
declare const RoleManager: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
511
|
+
api: {
|
|
512
|
+
type: PropType<SystemRoleApi>;
|
|
513
|
+
required: true;
|
|
514
|
+
};
|
|
515
|
+
title: {
|
|
516
|
+
type: StringConstructor;
|
|
517
|
+
default: string;
|
|
518
|
+
};
|
|
519
|
+
pageSize: {
|
|
520
|
+
type: StringConstructor;
|
|
521
|
+
default: string;
|
|
522
|
+
};
|
|
523
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
524
|
+
[key: string]: any;
|
|
525
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
526
|
+
api: {
|
|
527
|
+
type: PropType<SystemRoleApi>;
|
|
528
|
+
required: true;
|
|
529
|
+
};
|
|
530
|
+
title: {
|
|
531
|
+
type: StringConstructor;
|
|
532
|
+
default: string;
|
|
533
|
+
};
|
|
534
|
+
pageSize: {
|
|
535
|
+
type: StringConstructor;
|
|
536
|
+
default: string;
|
|
537
|
+
};
|
|
538
|
+
}>> & Readonly<{}>, {
|
|
539
|
+
title: string;
|
|
540
|
+
pageSize: string;
|
|
541
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
542
|
+
|
|
543
|
+
type SystemAdminMenuKey = 'menu' | 'resource' | 'role';
|
|
439
544
|
type SystemAdminSubMenu = {
|
|
440
545
|
key: SystemAdminMenuKey;
|
|
441
546
|
label: string;
|
|
@@ -445,12 +550,12 @@ type SystemAdminMenuGroup = {
|
|
|
445
550
|
label: string;
|
|
446
551
|
children: SystemAdminSubMenu[];
|
|
447
552
|
};
|
|
448
|
-
/**
|
|
553
|
+
/** 系统管理菜单结构 */
|
|
449
554
|
declare const SYSTEM_ADMIN_MENU: SystemAdminMenuGroup;
|
|
450
555
|
declare const SYSTEM_ADMIN_DEFAULT_KEY: SystemAdminMenuKey;
|
|
451
556
|
|
|
452
557
|
/**
|
|
453
|
-
*
|
|
558
|
+
* 系统管理:侧栏父菜单「系统管理」,子菜单为菜单 / 权限点 / 角色管理。
|
|
454
559
|
*/
|
|
455
560
|
declare const SystemAdmin: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
456
561
|
menuApi: {
|
|
@@ -461,6 +566,10 @@ declare const SystemAdmin: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
461
566
|
type: PropType<AuthorizationResourceApi>;
|
|
462
567
|
required: true;
|
|
463
568
|
};
|
|
569
|
+
roleApi: {
|
|
570
|
+
type: PropType<SystemRoleApi>;
|
|
571
|
+
required: true;
|
|
572
|
+
};
|
|
464
573
|
defaultActiveKey: {
|
|
465
574
|
type: PropType<SystemAdminMenuKey>;
|
|
466
575
|
default: SystemAdminMenuKey;
|
|
@@ -487,6 +596,10 @@ declare const SystemAdmin: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
487
596
|
type: PropType<AuthorizationResourceApi>;
|
|
488
597
|
required: true;
|
|
489
598
|
};
|
|
599
|
+
roleApi: {
|
|
600
|
+
type: PropType<SystemRoleApi>;
|
|
601
|
+
required: true;
|
|
602
|
+
};
|
|
490
603
|
defaultActiveKey: {
|
|
491
604
|
type: PropType<SystemAdminMenuKey>;
|
|
492
605
|
default: SystemAdminMenuKey;
|
|
@@ -538,4 +651,4 @@ declare const snowyflake: ConfigurableSnowflake;
|
|
|
538
651
|
declare function getAppClientId(): string;
|
|
539
652
|
declare function getDeviceWorkerId(): string;
|
|
540
653
|
|
|
541
|
-
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
|
654
|
+
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type CreateSystemRoleBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type FetchSystemRolesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, type PermissionStoreAPI, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, RoleManager, type RolePermissionTreeNode, type RolePermissionsResult, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, type SaveRolePermissionsBody, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type SystemRole, type SystemRoleApi, type SystemRoleFormValues, type SystemRoleListResult, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UpdateSystemRoleBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildCreateRoleBody, buildSavePermissionsBody, buildUpdateBody, buildUpdateMenuBody, buildUpdateRoleBody, collectTreeResourceIds, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createSystemRoleApi, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, mapPermissionTreeNode, mapRolePermissions, mapSystemRole, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
package/dist/vue/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { InjectionKey, ComputedRef, Plugin, Directive, PropType } from 'vue';
|
|
2
|
+
import { InjectionKey, ComputedRef, Plugin, Directive, PropType, VNode } from 'vue';
|
|
3
3
|
|
|
4
4
|
type PermissionCode = string;
|
|
5
5
|
type RoleCode = string;
|
|
@@ -26,12 +26,25 @@ interface PermissionChecker {
|
|
|
26
26
|
can(codes: PermissionCode | PermissionCode[], options?: CheckOptions): boolean;
|
|
27
27
|
getState(): PermissionState;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 权限 store 的公共接口(不含 class private 字段)。
|
|
31
|
+
* 用于跨入口(主包 / react / vue)传参,避免重复打包后的名义类型冲突。
|
|
32
|
+
*/
|
|
33
|
+
interface PermissionStoreAPI extends PermissionChecker {
|
|
34
|
+
setState(next: Partial<PermissionState>): void;
|
|
35
|
+
setPermissions(permissions: PermissionCode[]): void;
|
|
36
|
+
setRoles(roles: RoleCode[]): void;
|
|
37
|
+
setSuperAdmin(isSuperAdmin: boolean): void;
|
|
38
|
+
hydrate(payload: Partial<PermissionState>): void;
|
|
39
|
+
clear(): void;
|
|
40
|
+
subscribe(listener: PermissionListener): () => void;
|
|
41
|
+
}
|
|
29
42
|
|
|
30
43
|
/**
|
|
31
44
|
* Mutable permission store shared by React / Vue adapters.
|
|
32
45
|
* Framework-agnostic — safe to use in Node, browser, or any UI lib.
|
|
33
46
|
*/
|
|
34
|
-
declare class PermissionStore implements
|
|
47
|
+
declare class PermissionStore implements PermissionStoreAPI {
|
|
35
48
|
private state;
|
|
36
49
|
private permissionSet;
|
|
37
50
|
private roleSet;
|
|
@@ -53,19 +66,19 @@ declare class PermissionStore implements PermissionChecker {
|
|
|
53
66
|
subscribe(listener: PermissionListener): () => void;
|
|
54
67
|
private emit;
|
|
55
68
|
}
|
|
56
|
-
declare function createPermissionStore(initial?: Partial<PermissionState>):
|
|
69
|
+
declare function createPermissionStore(initial?: Partial<PermissionState>): PermissionStoreAPI;
|
|
57
70
|
|
|
58
|
-
declare const PERMISSION_STORE_KEY: InjectionKey<
|
|
71
|
+
declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStoreAPI>;
|
|
59
72
|
interface PermissionPluginOptions {
|
|
60
73
|
/** Pass an existing store to share across apps. */
|
|
61
|
-
store?:
|
|
74
|
+
store?: PermissionStoreAPI;
|
|
62
75
|
/** Initial state when the plugin creates its own store. */
|
|
63
76
|
initialState?: Partial<PermissionState>;
|
|
64
77
|
/** Custom directive name. Default: `permission` → `v-permission`. */
|
|
65
78
|
directiveName?: string;
|
|
66
79
|
}
|
|
67
80
|
declare function createPermissionPlugin(options?: PermissionPluginOptions): Plugin & {
|
|
68
|
-
store:
|
|
81
|
+
store: PermissionStoreAPI;
|
|
69
82
|
};
|
|
70
83
|
interface UsePermissionResult {
|
|
71
84
|
permissions: ComputedRef<PermissionCode[]>;
|
|
@@ -79,17 +92,17 @@ interface UsePermissionResult {
|
|
|
79
92
|
setSuperAdmin: (isSuperAdmin: boolean) => void;
|
|
80
93
|
hydrate: (payload: Partial<PermissionState>) => void;
|
|
81
94
|
clear: () => void;
|
|
82
|
-
store:
|
|
95
|
+
store: PermissionStoreAPI;
|
|
83
96
|
}
|
|
84
97
|
/**
|
|
85
98
|
* Reactive permission API for Vue 3 Composition API.
|
|
86
99
|
*/
|
|
87
|
-
declare function usePermission(store?:
|
|
88
|
-
declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?:
|
|
89
|
-
declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?:
|
|
100
|
+
declare function usePermission(store?: PermissionStoreAPI): UsePermissionResult;
|
|
101
|
+
declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?: PermissionStoreAPI): ComputedRef<boolean>;
|
|
102
|
+
declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?: PermissionStoreAPI): ComputedRef<boolean>;
|
|
90
103
|
declare module 'vue' {
|
|
91
104
|
interface ComponentCustomProperties {
|
|
92
|
-
$permission:
|
|
105
|
+
$permission: PermissionStoreAPI;
|
|
93
106
|
$can: (codes: PermissionCode | PermissionCode[], options?: CheckOptions) => boolean;
|
|
94
107
|
$hasRole: (codes: RoleCode | RoleCode[], options?: CheckOptions) => boolean;
|
|
95
108
|
}
|
|
@@ -112,7 +125,7 @@ type ElWithPermission = HTMLElement & {
|
|
|
112
125
|
* Create a `v-permission` directive bound to a specific store.
|
|
113
126
|
* Prefer installing via `createPermissionPlugin()` which registers this automatically.
|
|
114
127
|
*/
|
|
115
|
-
declare function createVPermission(store:
|
|
128
|
+
declare function createVPermission(store: PermissionStoreAPI): Directive<ElWithPermission, PermissionDirectiveValue>;
|
|
116
129
|
|
|
117
130
|
/**
|
|
118
131
|
* Conditionally render slot content based on permission / role.
|
|
@@ -435,7 +448,99 @@ declare const MenuManager: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
435
448
|
pageSize: string;
|
|
436
449
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
437
450
|
|
|
438
|
-
type
|
|
451
|
+
type SystemRole = {
|
|
452
|
+
roleId: string;
|
|
453
|
+
name: string;
|
|
454
|
+
description: string;
|
|
455
|
+
};
|
|
456
|
+
type SystemRoleFormValues = {
|
|
457
|
+
name: string;
|
|
458
|
+
description: string;
|
|
459
|
+
};
|
|
460
|
+
type CreateSystemRoleBody = SystemRoleFormValues;
|
|
461
|
+
type UpdateSystemRoleBody = Partial<SystemRoleFormValues>;
|
|
462
|
+
type FetchSystemRolesParams = {
|
|
463
|
+
keyword?: string;
|
|
464
|
+
pagination?: ListPaginationParams;
|
|
465
|
+
};
|
|
466
|
+
type SystemRoleListResult = {
|
|
467
|
+
records: SystemRole[];
|
|
468
|
+
pageToken: string;
|
|
469
|
+
hasPreviousPage: boolean;
|
|
470
|
+
hasNextPage: boolean;
|
|
471
|
+
};
|
|
472
|
+
/** 角色授权树节点 */
|
|
473
|
+
type RolePermissionTreeNode = {
|
|
474
|
+
resourceId: string;
|
|
475
|
+
name: string;
|
|
476
|
+
children: RolePermissionTreeNode[];
|
|
477
|
+
};
|
|
478
|
+
/** GET /system/roles/{role-id}/permissions */
|
|
479
|
+
type RolePermissionsResult = {
|
|
480
|
+
/** 当前角色已授予的资源 ID,用于树回显勾选 */
|
|
481
|
+
resourceIds: string[];
|
|
482
|
+
resourceTree: RolePermissionTreeNode[];
|
|
483
|
+
};
|
|
484
|
+
/** POST /system/roles/{role-id}/permissions */
|
|
485
|
+
type SaveRolePermissionsBody = {
|
|
486
|
+
resourceIds: string[];
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
type SystemRoleApi = {
|
|
490
|
+
list: (params?: FetchSystemRolesParams, signal?: AbortSignal) => Promise<SystemRoleListResult>;
|
|
491
|
+
create: (values: SystemRoleFormValues, signal?: AbortSignal) => Promise<unknown>;
|
|
492
|
+
update: (roleId: string, values: SystemRoleFormValues, signal?: AbortSignal) => Promise<unknown>;
|
|
493
|
+
remove: (roleId: string, signal?: AbortSignal) => Promise<unknown>;
|
|
494
|
+
getPermissions: (roleId: string, signal?: AbortSignal) => Promise<RolePermissionsResult>;
|
|
495
|
+
savePermissions: (roleId: string, resourceIds: string[], signal?: AbortSignal) => Promise<unknown>;
|
|
496
|
+
};
|
|
497
|
+
declare function mapSystemRole(item: unknown): SystemRole | null;
|
|
498
|
+
declare function mapPermissionTreeNode(item: unknown): RolePermissionTreeNode | null;
|
|
499
|
+
declare function mapRolePermissions(payload: unknown): RolePermissionsResult;
|
|
500
|
+
/** 收集节点及其全部子孙 resourceId */
|
|
501
|
+
declare function collectTreeResourceIds(node: RolePermissionTreeNode): string[];
|
|
502
|
+
declare function buildCreateRoleBody(values: SystemRoleFormValues): CreateSystemRoleBody;
|
|
503
|
+
declare function buildUpdateRoleBody(values: SystemRoleFormValues): UpdateSystemRoleBody;
|
|
504
|
+
declare function buildSavePermissionsBody(resourceIds: string[]): SaveRolePermissionsBody;
|
|
505
|
+
declare function createSystemRoleApi(request: ResourceHttpRequest): SystemRoleApi;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* 角色管理页面(Vue 3)
|
|
509
|
+
*/
|
|
510
|
+
declare const RoleManager: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
511
|
+
api: {
|
|
512
|
+
type: PropType<SystemRoleApi>;
|
|
513
|
+
required: true;
|
|
514
|
+
};
|
|
515
|
+
title: {
|
|
516
|
+
type: StringConstructor;
|
|
517
|
+
default: string;
|
|
518
|
+
};
|
|
519
|
+
pageSize: {
|
|
520
|
+
type: StringConstructor;
|
|
521
|
+
default: string;
|
|
522
|
+
};
|
|
523
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
524
|
+
[key: string]: any;
|
|
525
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
526
|
+
api: {
|
|
527
|
+
type: PropType<SystemRoleApi>;
|
|
528
|
+
required: true;
|
|
529
|
+
};
|
|
530
|
+
title: {
|
|
531
|
+
type: StringConstructor;
|
|
532
|
+
default: string;
|
|
533
|
+
};
|
|
534
|
+
pageSize: {
|
|
535
|
+
type: StringConstructor;
|
|
536
|
+
default: string;
|
|
537
|
+
};
|
|
538
|
+
}>> & Readonly<{}>, {
|
|
539
|
+
title: string;
|
|
540
|
+
pageSize: string;
|
|
541
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
542
|
+
|
|
543
|
+
type SystemAdminMenuKey = 'menu' | 'resource' | 'role';
|
|
439
544
|
type SystemAdminSubMenu = {
|
|
440
545
|
key: SystemAdminMenuKey;
|
|
441
546
|
label: string;
|
|
@@ -445,12 +550,12 @@ type SystemAdminMenuGroup = {
|
|
|
445
550
|
label: string;
|
|
446
551
|
children: SystemAdminSubMenu[];
|
|
447
552
|
};
|
|
448
|
-
/**
|
|
553
|
+
/** 系统管理菜单结构 */
|
|
449
554
|
declare const SYSTEM_ADMIN_MENU: SystemAdminMenuGroup;
|
|
450
555
|
declare const SYSTEM_ADMIN_DEFAULT_KEY: SystemAdminMenuKey;
|
|
451
556
|
|
|
452
557
|
/**
|
|
453
|
-
*
|
|
558
|
+
* 系统管理:侧栏父菜单「系统管理」,子菜单为菜单 / 权限点 / 角色管理。
|
|
454
559
|
*/
|
|
455
560
|
declare const SystemAdmin: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
456
561
|
menuApi: {
|
|
@@ -461,6 +566,10 @@ declare const SystemAdmin: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
461
566
|
type: PropType<AuthorizationResourceApi>;
|
|
462
567
|
required: true;
|
|
463
568
|
};
|
|
569
|
+
roleApi: {
|
|
570
|
+
type: PropType<SystemRoleApi>;
|
|
571
|
+
required: true;
|
|
572
|
+
};
|
|
464
573
|
defaultActiveKey: {
|
|
465
574
|
type: PropType<SystemAdminMenuKey>;
|
|
466
575
|
default: SystemAdminMenuKey;
|
|
@@ -487,6 +596,10 @@ declare const SystemAdmin: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
487
596
|
type: PropType<AuthorizationResourceApi>;
|
|
488
597
|
required: true;
|
|
489
598
|
};
|
|
599
|
+
roleApi: {
|
|
600
|
+
type: PropType<SystemRoleApi>;
|
|
601
|
+
required: true;
|
|
602
|
+
};
|
|
490
603
|
defaultActiveKey: {
|
|
491
604
|
type: PropType<SystemAdminMenuKey>;
|
|
492
605
|
default: SystemAdminMenuKey;
|
|
@@ -538,4 +651,4 @@ declare const snowyflake: ConfigurableSnowflake;
|
|
|
538
651
|
declare function getAppClientId(): string;
|
|
539
652
|
declare function getDeviceWorkerId(): string;
|
|
540
653
|
|
|
541
|
-
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
|
654
|
+
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type CreateSystemRoleBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type FetchSystemRolesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, type PermissionStoreAPI, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, RoleManager, type RolePermissionTreeNode, type RolePermissionsResult, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, type SaveRolePermissionsBody, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type SystemRole, type SystemRoleApi, type SystemRoleFormValues, type SystemRoleListResult, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UpdateSystemRoleBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildCreateRoleBody, buildSavePermissionsBody, buildUpdateBody, buildUpdateMenuBody, buildUpdateRoleBody, collectTreeResourceIds, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createSystemRoleApi, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, mapPermissionTreeNode, mapRolePermissions, mapSystemRole, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|