2022-10-06 02:29:53 +00:00
|
|
|
|
# ACLResource
|
|
|
|
|
|
|
|
|
|
ACLResource,ACL 系统中的资源类。在 ACL 系统中,为用户授予权限时会自动创建对应的资源。
|
|
|
|
|
|
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
## 类方法
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
### `constructor()`
|
|
|
|
|
构造函数
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
**签名**
|
|
|
|
|
* `constructor(options: AclResourceOptions)`
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
**类型**
|
2022-10-06 02:29:53 +00:00
|
|
|
|
```typescript
|
|
|
|
|
type ResourceActions = { [key: string]: RoleActionParams };
|
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
interface AclResourceOptions {
|
|
|
|
|
name: string; // 资源名称
|
|
|
|
|
role: ACLRole; // 资源所属角色
|
|
|
|
|
actions?: ResourceActions;
|
|
|
|
|
}
|
|
|
|
|
```
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
**详细信息**
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
`RoleActionParams`详见 [`aclRole.grantAction`](./acl-role.md#grantaction)
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
|
|
|
|
### `getActions()`
|
|
|
|
|
|
|
|
|
|
获取资源的所有 Action,返回结果为 `ResourceActions` 对象。
|
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
### `getAction()`
|
2022-10-06 02:29:53 +00:00
|
|
|
|
根据名称返回 Action 的参数配置,返回结果为 `RoleActionParams` 对象。
|
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
**详细信息**
|
|
|
|
|
|
|
|
|
|
`RoleActionParams`详见 [`aclRole.grantAction`](./acl-role.md#grantaction)
|
|
|
|
|
|
|
|
|
|
### `setAction()`
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
|
|
|
|
在资源内部设置一个 Action 的参数配置,返回结果为 `RoleActionParams` 对象。
|
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
**签名**
|
|
|
|
|
* `setAction(name: string, params: RoleActionParams)`
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
**详细信息**
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
* name - 要设置的 action 名称
|
|
|
|
|
* `RoleActionParams`详见 [`aclRole.grantAction`](./acl-role.md#grantaction)
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
### `setActions()`
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
**签名**
|
|
|
|
|
* `setActions(actions: ResourceActions)`
|
2022-10-06 02:29:53 +00:00
|
|
|
|
|
2022-10-16 11:16:14 +00:00
|
|
|
|
批量调用 `setAction` 的便捷方法
|