com-angel-authorization 1.0.10 → 1.0.14

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.
@@ -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 PermissionChecker {
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>): PermissionStore;
69
+ declare function createPermissionStore(initial?: Partial<PermissionState>): PermissionStoreAPI;
57
70
 
58
- declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStore>;
71
+ declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStoreAPI>;
59
72
  interface PermissionPluginOptions {
60
73
  /** Pass an existing store to share across apps. */
61
- store?: PermissionStore;
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: PermissionStore;
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: PermissionStore;
95
+ store: PermissionStoreAPI;
83
96
  }
84
97
  /**
85
98
  * Reactive permission API for Vue 3 Composition API.
86
99
  */
87
- declare function usePermission(store?: PermissionStore): UsePermissionResult;
88
- declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?: PermissionStore): ComputedRef<boolean>;
89
- declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?: PermissionStore): ComputedRef<boolean>;
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: PermissionStore;
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: PermissionStore): Directive<ElWithPermission, PermissionDirectiveValue>;
128
+ declare function createVPermission(store: PermissionStoreAPI): Directive<ElWithPermission, PermissionDirectiveValue>;
116
129
 
117
130
  /**
118
131
  * Conditionally render slot content based on permission / role.
@@ -538,4 +551,4 @@ declare const snowyflake: ConfigurableSnowflake;
538
551
  declare function getAppClientId(): string;
539
552
  declare function getDeviceWorkerId(): string;
540
553
 
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 };
554
+ 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, 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, 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 };
@@ -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 PermissionChecker {
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>): PermissionStore;
69
+ declare function createPermissionStore(initial?: Partial<PermissionState>): PermissionStoreAPI;
57
70
 
58
- declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStore>;
71
+ declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStoreAPI>;
59
72
  interface PermissionPluginOptions {
60
73
  /** Pass an existing store to share across apps. */
61
- store?: PermissionStore;
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: PermissionStore;
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: PermissionStore;
95
+ store: PermissionStoreAPI;
83
96
  }
84
97
  /**
85
98
  * Reactive permission API for Vue 3 Composition API.
86
99
  */
87
- declare function usePermission(store?: PermissionStore): UsePermissionResult;
88
- declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?: PermissionStore): ComputedRef<boolean>;
89
- declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?: PermissionStore): ComputedRef<boolean>;
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: PermissionStore;
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: PermissionStore): Directive<ElWithPermission, PermissionDirectiveValue>;
128
+ declare function createVPermission(store: PermissionStoreAPI): Directive<ElWithPermission, PermissionDirectiveValue>;
116
129
 
117
130
  /**
118
131
  * Conditionally render slot content based on permission / role.
@@ -538,4 +551,4 @@ declare const snowyflake: ConfigurableSnowflake;
538
551
  declare function getAppClientId(): string;
539
552
  declare function getDeviceWorkerId(): string;
540
553
 
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 };
554
+ 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, 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, 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 };
package/dist/vue/index.js CHANGED
@@ -1644,7 +1644,9 @@ var s2 = {
1644
1644
  border: "none",
1645
1645
  display: "flex",
1646
1646
  flexDirection: "column",
1647
- gap: "8px"
1647
+ gap: "8px",
1648
+ backgroundColor: "transparent",
1649
+ color: "#101828"
1648
1650
  },
1649
1651
  label: { fontSize: "13px", color: "#344054", fontWeight: "500" },
1650
1652
  input: {
@@ -1658,14 +1660,29 @@ var s2 = {
1658
1660
  boxSizing: "border-box",
1659
1661
  width: "100%"
1660
1662
  },
1661
- radioGroup: { display: "flex", flexWrap: "wrap", gap: "16px" },
1663
+ control: {
1664
+ width: "16px",
1665
+ height: "16px",
1666
+ margin: "0",
1667
+ flexShrink: "0",
1668
+ accentColor: "#049BAD",
1669
+ backgroundColor: "#ffffff",
1670
+ colorScheme: "light"
1671
+ },
1672
+ radioGroup: {
1673
+ display: "flex",
1674
+ flexWrap: "wrap",
1675
+ gap: "16px",
1676
+ backgroundColor: "transparent"
1677
+ },
1662
1678
  radioItem: {
1663
1679
  display: "flex",
1664
1680
  alignItems: "center",
1665
1681
  gap: "6px",
1666
1682
  fontSize: "14px",
1667
1683
  color: "#344054",
1668
- cursor: "pointer"
1684
+ cursor: "pointer",
1685
+ backgroundColor: "transparent"
1669
1686
  },
1670
1687
  multiSelect: {
1671
1688
  maxHeight: "160px",
@@ -1673,7 +1690,8 @@ var s2 = {
1673
1690
  border: "1px solid #eaecf0",
1674
1691
  borderRadius: "8px",
1675
1692
  padding: "8px",
1676
- background: "#f9fafb"
1693
+ backgroundColor: "#ffffff",
1694
+ color: "#101828"
1677
1695
  },
1678
1696
  checkItem: {
1679
1697
  display: "flex",
@@ -1682,7 +1700,8 @@ var s2 = {
1682
1700
  padding: "6px 4px",
1683
1701
  fontSize: "13px",
1684
1702
  color: "#344054",
1685
- cursor: "pointer"
1703
+ cursor: "pointer",
1704
+ backgroundColor: "transparent"
1686
1705
  },
1687
1706
  hint: { fontSize: "13px", color: "#98a2b3", padding: "8px" },
1688
1707
  dialogFooter: {
@@ -2120,14 +2139,6 @@ var MenuManager = defineComponent3({
2120
2139
  ]
2121
2140
  )
2122
2141
  ]),
2123
- h2("div", { style: s2.field }, [
2124
- h2("span", { style: s2.label }, "\u83DC\u5355\u5C42\u7EA7\uFF08depth\uFF09"),
2125
- h2("input", {
2126
- style: s2.input,
2127
- value: form.depth,
2128
- readOnly: true
2129
- })
2130
- ]),
2131
2142
  h2("fieldset", { style: s2.fieldset }, [
2132
2143
  h2("legend", { style: s2.label }, "\u83DC\u5355\u7C7B\u578B"),
2133
2144
  h2(
@@ -2138,6 +2149,7 @@ var MenuManager = defineComponent3({
2138
2149
  h2("input", {
2139
2150
  type: "radio",
2140
2151
  name: "menu-type",
2152
+ style: s2.control,
2141
2153
  checked: form.type === opt.value,
2142
2154
  onChange: () => {
2143
2155
  form.type = opt.value;
@@ -2189,6 +2201,7 @@ var MenuManager = defineComponent3({
2189
2201
  [
2190
2202
  h2("input", {
2191
2203
  type: "checkbox",
2204
+ style: s2.control,
2192
2205
  checked: form.permissionPointIds.includes(
2193
2206
  p.resourceId
2194
2207
  ),
@@ -2222,6 +2235,7 @@ var MenuManager = defineComponent3({
2222
2235
  h2("input", {
2223
2236
  type: "radio",
2224
2237
  name: "menu-status",
2238
+ style: s2.control,
2225
2239
  checked: form.status === opt.value,
2226
2240
  onChange: () => {
2227
2241
  form.status = opt.value;