com-angel-authorization 1.0.15 → 1.0.17
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 +1 -1
- package/dist/index.cjs +71 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +67 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +78 -26
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +22 -1
- package/dist/react/index.d.ts +22 -1
- package/dist/react/index.js +73 -26
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.cjs +82 -24
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +22 -1
- package/dist/vue/index.d.ts +22 -1
- package/dist/vue/index.js +77 -24
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -390,6 +390,27 @@ declare function mapPermissionTreeNode(item: unknown): RolePermissionTreeNode |
|
|
|
390
390
|
declare function mapRolePermissions(payload: unknown): RolePermissionsResult;
|
|
391
391
|
/** 收集节点及其全部子孙 resourceId */
|
|
392
392
|
declare function collectTreeResourceIds(node: RolePermissionTreeNode): string[];
|
|
393
|
+
type PermissionTreeIndex = {
|
|
394
|
+
parentMap: Map<string, string | null>;
|
|
395
|
+
nodeMap: Map<string, RolePermissionTreeNode>;
|
|
396
|
+
};
|
|
397
|
+
/** 建立父节点索引,供父子联动向上回写 */
|
|
398
|
+
declare function buildPermissionTreeIndex(tree: RolePermissionTreeNode[]): PermissionTreeIndex;
|
|
399
|
+
/**
|
|
400
|
+
* 父子联动勾选:
|
|
401
|
+
* - 勾选:当前节点 + 全部子孙选中,并向上:子节点全选则父节点选中
|
|
402
|
+
* - 取消:当前节点 + 全部子孙取消,并向上:任一子未选则父节点取消(半选由 UI 展示)
|
|
403
|
+
*/
|
|
404
|
+
declare function togglePermissionCheck(tree: RolePermissionTreeNode[], checked: ReadonlySet<string>, node: RolePermissionTreeNode): Set<string>;
|
|
405
|
+
/** 子孙勾选统计(不含自身),用于半选态 */
|
|
406
|
+
declare function countCheckedDescendants(node: RolePermissionTreeNode, checked: ReadonlySet<string>): {
|
|
407
|
+
total: number;
|
|
408
|
+
checkedCount: number;
|
|
409
|
+
};
|
|
410
|
+
/** 是否存在已勾选的子孙节点 */
|
|
411
|
+
declare function hasCheckedDescendant(node: RolePermissionTreeNode, checked: ReadonlySet<string>): boolean;
|
|
412
|
+
/** 半选:自身未勾选,但存在已勾选的子孙 */
|
|
413
|
+
declare function isPermissionNodeIndeterminate(node: RolePermissionTreeNode, checked: ReadonlySet<string>): boolean;
|
|
393
414
|
declare function buildCreateRoleBody(values: SystemRoleFormValues): CreateSystemRoleBody;
|
|
394
415
|
declare function buildUpdateRoleBody(values: SystemRoleFormValues): UpdateSystemRoleBody;
|
|
395
416
|
declare function buildSavePermissionsBody(resourceIds: string[]): SaveRolePermissionsBody;
|
|
@@ -464,4 +485,4 @@ declare const snowyflake: ConfigurableSnowflake;
|
|
|
464
485
|
declare function getAppClientId(): string;
|
|
465
486
|
declare function getDeviceWorkerId(): string;
|
|
466
487
|
|
|
467
|
-
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, 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 MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, 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 ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, RoleManager, type RoleManagerProps, type RolePermissionTreeNode, type RolePermissionsResult, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, type SaveRolePermissionsBody, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, 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, createPermissionStore, createSystemRoleApi, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, mapPermissionTreeNode, mapRolePermissions, mapSystemRole, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
|
488
|
+
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, 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 MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, 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 ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, RoleManager, type RoleManagerProps, type RolePermissionTreeNode, type RolePermissionsResult, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, type SaveRolePermissionsBody, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type SystemRole, type SystemRoleApi, type SystemRoleFormValues, type SystemRoleListResult, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UpdateSystemRoleBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildCreateRoleBody, buildPermissionTreeIndex, buildSavePermissionsBody, buildUpdateBody, buildUpdateMenuBody, buildUpdateRoleBody, collectTreeResourceIds, countCheckedDescendants, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, createSystemRoleApi, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, hasCheckedDescendant, isMenuLeaf, isPermissionNodeIndeterminate, mapAuthorizationResource, mapMenuResource, mapPermissionTreeNode, mapRolePermissions, mapSystemRole, resolveMenuDepth, snowyflake, togglePermissionCheck, useHasPermission, useHasRole, usePermission };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -390,6 +390,27 @@ declare function mapPermissionTreeNode(item: unknown): RolePermissionTreeNode |
|
|
|
390
390
|
declare function mapRolePermissions(payload: unknown): RolePermissionsResult;
|
|
391
391
|
/** 收集节点及其全部子孙 resourceId */
|
|
392
392
|
declare function collectTreeResourceIds(node: RolePermissionTreeNode): string[];
|
|
393
|
+
type PermissionTreeIndex = {
|
|
394
|
+
parentMap: Map<string, string | null>;
|
|
395
|
+
nodeMap: Map<string, RolePermissionTreeNode>;
|
|
396
|
+
};
|
|
397
|
+
/** 建立父节点索引,供父子联动向上回写 */
|
|
398
|
+
declare function buildPermissionTreeIndex(tree: RolePermissionTreeNode[]): PermissionTreeIndex;
|
|
399
|
+
/**
|
|
400
|
+
* 父子联动勾选:
|
|
401
|
+
* - 勾选:当前节点 + 全部子孙选中,并向上:子节点全选则父节点选中
|
|
402
|
+
* - 取消:当前节点 + 全部子孙取消,并向上:任一子未选则父节点取消(半选由 UI 展示)
|
|
403
|
+
*/
|
|
404
|
+
declare function togglePermissionCheck(tree: RolePermissionTreeNode[], checked: ReadonlySet<string>, node: RolePermissionTreeNode): Set<string>;
|
|
405
|
+
/** 子孙勾选统计(不含自身),用于半选态 */
|
|
406
|
+
declare function countCheckedDescendants(node: RolePermissionTreeNode, checked: ReadonlySet<string>): {
|
|
407
|
+
total: number;
|
|
408
|
+
checkedCount: number;
|
|
409
|
+
};
|
|
410
|
+
/** 是否存在已勾选的子孙节点 */
|
|
411
|
+
declare function hasCheckedDescendant(node: RolePermissionTreeNode, checked: ReadonlySet<string>): boolean;
|
|
412
|
+
/** 半选:自身未勾选,但存在已勾选的子孙 */
|
|
413
|
+
declare function isPermissionNodeIndeterminate(node: RolePermissionTreeNode, checked: ReadonlySet<string>): boolean;
|
|
393
414
|
declare function buildCreateRoleBody(values: SystemRoleFormValues): CreateSystemRoleBody;
|
|
394
415
|
declare function buildUpdateRoleBody(values: SystemRoleFormValues): UpdateSystemRoleBody;
|
|
395
416
|
declare function buildSavePermissionsBody(resourceIds: string[]): SaveRolePermissionsBody;
|
|
@@ -464,4 +485,4 @@ declare const snowyflake: ConfigurableSnowflake;
|
|
|
464
485
|
declare function getAppClientId(): string;
|
|
465
486
|
declare function getDeviceWorkerId(): string;
|
|
466
487
|
|
|
467
|
-
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, 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 MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, 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 ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, RoleManager, type RoleManagerProps, type RolePermissionTreeNode, type RolePermissionsResult, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, type SaveRolePermissionsBody, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, 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, createPermissionStore, createSystemRoleApi, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, mapPermissionTreeNode, mapRolePermissions, mapSystemRole, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
|
488
|
+
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, 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 MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, 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 ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, RoleManager, type RoleManagerProps, type RolePermissionTreeNode, type RolePermissionsResult, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, type SaveRolePermissionsBody, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type SystemRole, type SystemRoleApi, type SystemRoleFormValues, type SystemRoleListResult, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UpdateSystemRoleBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildCreateRoleBody, buildPermissionTreeIndex, buildSavePermissionsBody, buildUpdateBody, buildUpdateMenuBody, buildUpdateRoleBody, collectTreeResourceIds, countCheckedDescendants, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, createSystemRoleApi, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, hasCheckedDescendant, isMenuLeaf, isPermissionNodeIndeterminate, mapAuthorizationResource, mapMenuResource, mapPermissionTreeNode, mapRolePermissions, mapSystemRole, resolveMenuDepth, snowyflake, togglePermissionCheck, useHasPermission, useHasRole, usePermission };
|
package/dist/react/index.js
CHANGED
|
@@ -2005,6 +2005,72 @@ function mapRolePermissions(payload) {
|
|
|
2005
2005
|
function collectTreeResourceIds(node) {
|
|
2006
2006
|
return [node.resourceId, ...node.children.flatMap(collectTreeResourceIds)];
|
|
2007
2007
|
}
|
|
2008
|
+
function buildPermissionTreeIndex(tree) {
|
|
2009
|
+
const parentMap = /* @__PURE__ */ new Map();
|
|
2010
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
2011
|
+
const walk = (nodes, parentId) => {
|
|
2012
|
+
for (const node of nodes) {
|
|
2013
|
+
parentMap.set(node.resourceId, parentId);
|
|
2014
|
+
nodeMap.set(node.resourceId, node);
|
|
2015
|
+
if (node.children.length > 0) {
|
|
2016
|
+
walk(node.children, node.resourceId);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
walk(tree, null);
|
|
2021
|
+
return { parentMap, nodeMap };
|
|
2022
|
+
}
|
|
2023
|
+
function togglePermissionCheck(tree, checked, node) {
|
|
2024
|
+
const next = new Set(checked);
|
|
2025
|
+
const ids = collectTreeResourceIds(node);
|
|
2026
|
+
const shouldCheck = !checked.has(node.resourceId);
|
|
2027
|
+
if (shouldCheck) {
|
|
2028
|
+
ids.forEach((id) => next.add(id));
|
|
2029
|
+
} else {
|
|
2030
|
+
ids.forEach((id) => next.delete(id));
|
|
2031
|
+
}
|
|
2032
|
+
const { parentMap, nodeMap } = buildPermissionTreeIndex(tree);
|
|
2033
|
+
let parentId = parentMap.get(node.resourceId) ?? null;
|
|
2034
|
+
while (parentId) {
|
|
2035
|
+
const parent = nodeMap.get(parentId);
|
|
2036
|
+
if (!parent) break;
|
|
2037
|
+
const allChildrenChecked = parent.children.every(
|
|
2038
|
+
(child) => next.has(child.resourceId)
|
|
2039
|
+
);
|
|
2040
|
+
if (allChildrenChecked && parent.children.length > 0) {
|
|
2041
|
+
next.add(parentId);
|
|
2042
|
+
} else {
|
|
2043
|
+
next.delete(parentId);
|
|
2044
|
+
}
|
|
2045
|
+
parentId = parentMap.get(parentId) ?? null;
|
|
2046
|
+
}
|
|
2047
|
+
return next;
|
|
2048
|
+
}
|
|
2049
|
+
function countCheckedDescendants(node, checked) {
|
|
2050
|
+
let total = 0;
|
|
2051
|
+
let checkedCount = 0;
|
|
2052
|
+
const walk = (n) => {
|
|
2053
|
+
for (const child of n.children) {
|
|
2054
|
+
total += 1;
|
|
2055
|
+
if (checked.has(child.resourceId)) checkedCount += 1;
|
|
2056
|
+
walk(child);
|
|
2057
|
+
}
|
|
2058
|
+
};
|
|
2059
|
+
walk(node);
|
|
2060
|
+
return { total, checkedCount };
|
|
2061
|
+
}
|
|
2062
|
+
function hasCheckedDescendant(node, checked) {
|
|
2063
|
+
for (const child of node.children) {
|
|
2064
|
+
if (checked.has(child.resourceId) || hasCheckedDescendant(child, checked)) {
|
|
2065
|
+
return true;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
return false;
|
|
2069
|
+
}
|
|
2070
|
+
function isPermissionNodeIndeterminate(node, checked) {
|
|
2071
|
+
if (checked.has(node.resourceId) || node.children.length === 0) return false;
|
|
2072
|
+
return hasCheckedDescendant(node, checked);
|
|
2073
|
+
}
|
|
2008
2074
|
function buildListUrl2(params) {
|
|
2009
2075
|
const parts = [];
|
|
2010
2076
|
appendQueryParam(parts, "keyword", params?.keyword ?? "");
|
|
@@ -2093,19 +2159,6 @@ var emptyForm3 = () => ({
|
|
|
2093
2159
|
name: "",
|
|
2094
2160
|
description: ""
|
|
2095
2161
|
});
|
|
2096
|
-
function countCheckedDescendants(node, checked) {
|
|
2097
|
-
let total = 0;
|
|
2098
|
-
let checkedCount = 0;
|
|
2099
|
-
const walk = (n) => {
|
|
2100
|
-
for (const child of n.children) {
|
|
2101
|
-
total += 1;
|
|
2102
|
-
if (checked.has(child.resourceId)) checkedCount += 1;
|
|
2103
|
-
walk(child);
|
|
2104
|
-
}
|
|
2105
|
-
};
|
|
2106
|
-
walk(node);
|
|
2107
|
-
return { total, checkedCount };
|
|
2108
|
-
}
|
|
2109
2162
|
function RoleManager({
|
|
2110
2163
|
api,
|
|
2111
2164
|
title = "\u89D2\u8272\u7BA1\u7406",
|
|
@@ -2260,17 +2313,7 @@ function RoleManager({
|
|
|
2260
2313
|
setAuthExpanded((prev) => ({ ...prev, [resourceId]: !prev[resourceId] }));
|
|
2261
2314
|
};
|
|
2262
2315
|
const toggleCheck = (node) => {
|
|
2263
|
-
setAuthChecked((prev) =>
|
|
2264
|
-
const next = new Set(prev);
|
|
2265
|
-
const ids = collectTreeResourceIds(node);
|
|
2266
|
-
const shouldCheck = !prev.has(node.resourceId);
|
|
2267
|
-
if (shouldCheck) {
|
|
2268
|
-
ids.forEach((id) => next.add(id));
|
|
2269
|
-
} else {
|
|
2270
|
-
ids.forEach((id) => next.delete(id));
|
|
2271
|
-
}
|
|
2272
|
-
return next;
|
|
2273
|
-
});
|
|
2316
|
+
setAuthChecked((prev) => togglePermissionCheck(authTree, prev, node));
|
|
2274
2317
|
};
|
|
2275
2318
|
const saveAuthorize = async () => {
|
|
2276
2319
|
if (!authRole) return;
|
|
@@ -2289,8 +2332,7 @@ function RoleManager({
|
|
|
2289
2332
|
const hasChildren = node.children.length > 0;
|
|
2290
2333
|
const expanded = Boolean(authExpanded[node.resourceId]);
|
|
2291
2334
|
const checked = authChecked.has(node.resourceId);
|
|
2292
|
-
const
|
|
2293
|
-
const indeterminate = hasChildren && checkedCount > 0 && checkedCount < total && !checked;
|
|
2335
|
+
const indeterminate = isPermissionNodeIndeterminate(node, authChecked);
|
|
2294
2336
|
return /* @__PURE__ */ jsxs3("div", { children: [
|
|
2295
2337
|
/* @__PURE__ */ jsxs3("div", { style: { ...styles3.treeRow, paddingLeft: 12 + depth * 20 }, children: [
|
|
2296
2338
|
hasChildren ? /* @__PURE__ */ jsx4(
|
|
@@ -2975,11 +3017,13 @@ export {
|
|
|
2975
3017
|
buildCreateBody,
|
|
2976
3018
|
buildCreateMenuBody,
|
|
2977
3019
|
buildCreateRoleBody,
|
|
3020
|
+
buildPermissionTreeIndex,
|
|
2978
3021
|
buildSavePermissionsBody,
|
|
2979
3022
|
buildUpdateBody,
|
|
2980
3023
|
buildUpdateMenuBody,
|
|
2981
3024
|
buildUpdateRoleBody,
|
|
2982
3025
|
collectTreeResourceIds,
|
|
3026
|
+
countCheckedDescendants,
|
|
2983
3027
|
createAuthorizationResourceApi,
|
|
2984
3028
|
createDefaultResourceRequest,
|
|
2985
3029
|
createMenuResourceApi,
|
|
@@ -2989,7 +3033,9 @@ export {
|
|
|
2989
3033
|
extractRecords,
|
|
2990
3034
|
getAppClientId,
|
|
2991
3035
|
getDeviceWorkerId,
|
|
3036
|
+
hasCheckedDescendant,
|
|
2992
3037
|
isMenuLeaf,
|
|
3038
|
+
isPermissionNodeIndeterminate,
|
|
2993
3039
|
mapAuthorizationResource,
|
|
2994
3040
|
mapMenuResource,
|
|
2995
3041
|
mapPermissionTreeNode,
|
|
@@ -2997,6 +3043,7 @@ export {
|
|
|
2997
3043
|
mapSystemRole,
|
|
2998
3044
|
resolveMenuDepth,
|
|
2999
3045
|
snowyflake,
|
|
3046
|
+
togglePermissionCheck,
|
|
3000
3047
|
useHasPermission,
|
|
3001
3048
|
useHasRole,
|
|
3002
3049
|
usePermission
|