mirror of https://github.com/abpframework/abp
parent
f87158eb23
commit
18d22c163c
@ -0,0 +1 @@
|
||||
TODO...
|
||||
@ -0,0 +1 @@
|
||||
TODO...
|
||||
@ -0,0 +1 @@
|
||||
TODO...
|
||||
@ -0,0 +1 @@
|
||||
TODO...
|
||||
@ -1,3 +1,167 @@
|
||||
# Current User
|
||||
# 当前用户
|
||||
|
||||
TODO!
|
||||
在Web应用程序中检索有关已登录用户的信息是很常见的. 当前用户是与Web应用程序中的当前请求相关的活动用户.
|
||||
|
||||
## ICurrentUser
|
||||
|
||||
`ICurrentUser` 是主要的服务,用于获取有关当前活动的用户信息.
|
||||
|
||||
示例: [注入](Dependency-Injection.md) `ICurrentUser` 到服务中:
|
||||
|
||||
````csharp
|
||||
using System;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Users;
|
||||
|
||||
namespace AbpDemo
|
||||
{
|
||||
public class MyService : ITransientDependency
|
||||
{
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public MyService(ICurrentUser currentUser)
|
||||
{
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public void Foo()
|
||||
{
|
||||
Guid? userId = _currentUser.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
公共基类已经将此服务作为基本属性注入. 例如你可以直接在[应用服务](Application-Services.md)中使用 `CurrentUser` 属性:
|
||||
|
||||
````csharp
|
||||
using System;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace AbpDemo
|
||||
{
|
||||
public class MyAppService : ApplicationService
|
||||
{
|
||||
public void Foo()
|
||||
{
|
||||
Guid? userId = CurrentUser.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
### 属性
|
||||
|
||||
以下是 `ICurrentUser` 接口的基本属性:
|
||||
|
||||
* **IsAuthenticated** 如果当前用户已登录(已认证),则返回 `true`. 如果用户尚未登录,则 `Id` 和 `UserName` 将返回 `null`.
|
||||
* **Id** (Guid?): 当前用户的Id,如果用户未登录,返回 `null`.
|
||||
* **UserName** (string): 当前用户的用户名称. 如果用户未登录,返回 `null`.
|
||||
* **TenantId** (Guid?): 当前用户的租户Id. 对于[多租户](Multi-Tenancy.md) 应用程序很有用. 如果当前用户未分配给租户,返回 `null`.
|
||||
* **Email** (string): 当前用户的电子邮件地址. 如果当前用户尚未登录或未设置电子邮件地址,返回 `null`.
|
||||
* **EmailVerified** (bool): 如果当前用户的电子邮件地址已经过验证,返回 `true`.
|
||||
* **PhoneNumber** (string): 当前用户的电话号码. 如果当前用户尚未登录或未设置电话号码,返回 `null`.
|
||||
* **PhoneNumberVerified** (bool): 如果当前用户的电话号码已经过验证,返回 `true`.
|
||||
* **Roles** (string[]): 当前用户的角色. 返回当前用户角色名称的字符串数组.
|
||||
|
||||
### Methods
|
||||
|
||||
`ICurrentUser` 是在 `ICurrentPrincipalAccessor` 上实现的(请参阅以下部分),并可以处理声明. 实际上所有上述属性都是从当前经过身份验证的用户的声明中检索的.
|
||||
|
||||
如果你有自定义声明或获取其他非常见声明类型, `ICurrentUser` 有一些直接使用声明的方法.
|
||||
|
||||
* **FindClaim**: 获取给定名称的声明,如果未找到返回 `null`.
|
||||
* **FindClaims**: 获取具有给定名称的所有声明(允许具有相同名称的多个声明值).
|
||||
* **GetAllClaims**: 获取所有声明.
|
||||
* **IsInRole**: 一种检查当前用户是否在指定角色中的简化方法.
|
||||
|
||||
除了这些标准方法,还有一些扩展方法:
|
||||
|
||||
* **FindClaimValue**: 获取具有给定名称的声明的值,如果未找到返回 `null`. 它有一个泛型重载将值强制转换为特定类型.
|
||||
* **GetId**: 返回当前用户的 `Id`. 如果当前用户没有登录它会抛出一个异常(而不是返回`null`). 仅在你确定用户已经在你的代码上下文中进行了身份验证时才使用此选项.
|
||||
|
||||
### 验证和授权
|
||||
|
||||
`ICurrentUser` 的工作方式与用户的身份验证或授权方式无关. 它可以与使用当前主体的任何身份验证系统无缝地配合使用(请参阅下面的部分).
|
||||
|
||||
## ICurrentPrincipalAccessor
|
||||
|
||||
`ICurrentPrincipalAccessor` 是当需要当前用户的principle时使用的服务(由ABP框架和你的应用程序代码使用).
|
||||
|
||||
对于Web应用程序, 它获取当前 `HttpContext` 的 `User` 属性,对于非Web应用程序它将返回 `Thread.CurrentPrincipal`.
|
||||
|
||||
> 通常你不需要这种低级别的 `ICurrentPrincipalAccessor` 服务,直接使用上述的 `ICurrentUser` 即可.
|
||||
|
||||
### 基本用法
|
||||
|
||||
你可以注入 `ICurrentPrincipalAccessor` 并且使用 `Principal` 属性获取当前principal:
|
||||
|
||||
````csharp
|
||||
public class MyService : ITransientDependency
|
||||
{
|
||||
private readonly ICurrentPrincipalAccessor _currentPrincipalAccessor;
|
||||
|
||||
public MyService(ICurrentPrincipalAccessor currentPrincipalAccessor)
|
||||
{
|
||||
_currentPrincipalAccessor = currentPrincipalAccessor;
|
||||
}
|
||||
|
||||
public void Foo()
|
||||
{
|
||||
var allClaims = _currentPrincipalAccessor.Principal.Claims.ToList();
|
||||
//...
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
### 更改当前Principle
|
||||
|
||||
除了某些高级场景外,你不需要设置或更改当前principle. 如果需要可以使用 `ICurrentPrincipalAccessor` 的 `Change` 方法. 它接受一个 `ClaimsPrinciple` 对象并使其成为作用域的"当前"对象.
|
||||
|
||||
示例:
|
||||
|
||||
````csharp
|
||||
public class MyAppService : ApplicationService
|
||||
{
|
||||
private readonly ICurrentPrincipalAccessor _currentPrincipalAccessor;
|
||||
|
||||
public MyAppService(ICurrentPrincipalAccessor currentPrincipalAccessor)
|
||||
{
|
||||
_currentPrincipalAccessor = currentPrincipalAccessor;
|
||||
}
|
||||
|
||||
public void Foo()
|
||||
{
|
||||
var newPrinciple = new ClaimsPrincipal(
|
||||
new ClaimsIdentity(
|
||||
new Claim[]
|
||||
{
|
||||
new Claim(AbpClaimTypes.UserId, Guid.NewGuid().ToString()),
|
||||
new Claim(AbpClaimTypes.UserName, "john"),
|
||||
new Claim("MyCustomCliam", "42")
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
using (_currentPrincipalAccessor.Change(newPrinciple))
|
||||
{
|
||||
var userName = CurrentUser.UserName; //returns "john"
|
||||
//...
|
||||
}
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
始终在 `using` 语句中使用 `Change` 方法,在 `using` 范围结束后它将恢复为原始值.
|
||||
|
||||
这可以是一种模拟用户登录的应用程序代码范围的方法,但是请尝试谨慎使用它.
|
||||
|
||||
## AbpClaimTypes
|
||||
|
||||
`AbpClaimTypes` 是一个静态类它定义了标准声明的名称被ABP框架使用.
|
||||
|
||||
* `UserName`, `UserId`, `Role` 和 `Email` 属性的默认值是通常[System.Security.Claims.ClaimTypes](https://docs.microsoft.com/en-us/dotnet/api/system.security.claims.claimtypes)类设置的, 但你可以改变它们.
|
||||
|
||||
* 其他属性,如 `EmailVerified`, `PhoneNumber`, `TenantId` ...是由ABP框架通过尽可能遵循标准名称来定义的.
|
||||
|
||||
建议使用这个类的属性来代替声明名称的魔术字符串.
|
||||
@ -0,0 +1,19 @@
|
||||
# 控制台应用程序启动模板
|
||||
|
||||
此模板用于创建一个最小的依赖关系的ABP控制台应用程序项目.
|
||||
|
||||
## 如何开始?
|
||||
|
||||
首先,如果你没有安装[ABP CLI](../CLI.md),请先安装它:
|
||||
|
||||
````bash
|
||||
dotnet tool install -g Volo.Abp.Cli
|
||||
````
|
||||
|
||||
在一个空文件夹使用 `abp new` 命令创建新解决方案:
|
||||
|
||||
````bash
|
||||
abp new Acme.MyConsoleApp -t console
|
||||
````
|
||||
|
||||
`Acme.MyConsoleApp` 是解决方案的名称, 如*YourCompany.YourProduct*. 你可以使用单级或多级名称.
|
||||
@ -0,0 +1 @@
|
||||
TODO....
|
||||
@ -0,0 +1,38 @@
|
||||
# 徽章
|
||||
|
||||
## 结合扫
|
||||
|
||||
`abp-badge` 和 `abp-badge-pill` 是abp徽章标签.
|
||||
|
||||
基本用法:
|
||||
|
||||
````csharp
|
||||
<span abp-badge="Primary">Primary</span>
|
||||
<a abp-badge="Info" href="#">Info</a>
|
||||
<a abp-badge-pill="Danger" href="#">Danger</a>
|
||||
````
|
||||
|
||||
## Demo
|
||||
|
||||
参阅[徽章demo页面](https://bootstrap-taghelpers.abp.io/Components/Badges)查看示例.
|
||||
|
||||
### Values
|
||||
|
||||
* 表示徽章的类型. 应为下列值之一:
|
||||
|
||||
* `_` (默认值)
|
||||
* `Default` (默认值)
|
||||
* `Primary`
|
||||
* `Secondary`
|
||||
* `Success`
|
||||
* `Danger`
|
||||
* `Warning`
|
||||
* `Info`
|
||||
* `Light`
|
||||
* `Dark`
|
||||
|
||||
示例:
|
||||
|
||||
````csharp
|
||||
<span abp-badge-pill="Danger">Danger</span>
|
||||
````
|
||||
@ -0,0 +1,124 @@
|
||||
# 边框
|
||||
|
||||
## 介绍
|
||||
|
||||
`abp-border` 是边框样式的主要元素.
|
||||
|
||||
基本用法:
|
||||
|
||||
````csharp
|
||||
<span abp-border="Default"></span>
|
||||
<span abp-border="Top"></span>
|
||||
<span abp-border="Right"></span>
|
||||
<span abp-border="Bottom"></span>
|
||||
<span abp-border="Left"></span>
|
||||
````
|
||||
|
||||
## Demo
|
||||
|
||||
参阅[边框demo页面](https://bootstrap-taghelpers.abp.io/Components/Borders)查看示例.
|
||||
|
||||
## Values
|
||||
|
||||
值代表类型,位置和边框的颜色.应为下列值之一:
|
||||
|
||||
* `Default`
|
||||
* `_0`
|
||||
* `Primary`
|
||||
* `Secondary`
|
||||
* `Success`
|
||||
* `Danger`
|
||||
* `Warning`
|
||||
* `Info`
|
||||
* `Light`
|
||||
* `Dark`
|
||||
* `White`
|
||||
* `Primary_0`
|
||||
* `Secondary_0`
|
||||
* `Success_0`
|
||||
* `Danger_0`
|
||||
* `Warning_0`
|
||||
* `Info_0`
|
||||
* `Light_0`
|
||||
* `Dark_0`
|
||||
* `White_0`
|
||||
* `Top`
|
||||
* `Top_0`
|
||||
* `Top_Primary`
|
||||
* `Top_Secondary`
|
||||
* `Top_Success`
|
||||
* `Top_Danger`
|
||||
* `Top_Warning`
|
||||
* `Top_Info`
|
||||
* `Top_Light`
|
||||
* `Top_Dark`
|
||||
* `Top_White`
|
||||
* `Top_Primary_0`
|
||||
* `Top_Secondary_0`
|
||||
* `Top_Success_0`
|
||||
* `Top_Danger_0`
|
||||
* `Top_Warning_0`
|
||||
* `Top_Info_0`
|
||||
* `Top_Light_0`
|
||||
* `Top_Dark_0`
|
||||
* `Top_White_0`
|
||||
* `Right`
|
||||
* `Right_0`
|
||||
* `Right_Primary`
|
||||
* `Right_Secondary`
|
||||
* `Right_Success`
|
||||
* `Right_Danger`
|
||||
* `Right_Warning`
|
||||
* `Right_Info`
|
||||
* `Right_Light`
|
||||
* `Right_Dark`
|
||||
* `Right_White`
|
||||
* `Right_Primary_0`
|
||||
* `Right_Secondary_0`
|
||||
* `Right_Success_0`
|
||||
* `Right_Danger_0`
|
||||
* `Right_Warning_0`
|
||||
* `Right_Info_0`
|
||||
* `Right_Light_0`
|
||||
* `Right_Dark_0`
|
||||
* `Right_White_0`
|
||||
* `Left`
|
||||
* `Left_0`
|
||||
* `Left_Primary`
|
||||
* `Left_Secondary`
|
||||
* `Left_Success`
|
||||
* `Left_Danger`
|
||||
* `Left_Warning`
|
||||
* `Left_Info`
|
||||
* `Left_Light`
|
||||
* `Left_Dark`
|
||||
* `Left_White`
|
||||
* `Left_Primary_0`
|
||||
* `Left_Secondary_0`
|
||||
* `Left_Success_0`
|
||||
* `Left_Danger_0`
|
||||
* `Left_Warning_0`
|
||||
* `Left_Info_0`
|
||||
* `Left_Light_0`
|
||||
* `Left_Dark_0`
|
||||
* `Left_White_0`
|
||||
* `Bottom`
|
||||
* `Bottom_0`
|
||||
* `Bottom_Primary`
|
||||
* `Bottom_Secondary`
|
||||
* `Bottom_Success`
|
||||
* `Bottom_Danger`
|
||||
* `Bottom_Warning`
|
||||
* `Bottom_Info`
|
||||
* `Bottom_Light`
|
||||
* `Bottom_Dark`
|
||||
* `Bottom_White`
|
||||
* `Bottom_Primary_0`
|
||||
* `Bottom_Secondary_0`
|
||||
* `Bottom_Success_0`
|
||||
* `Bottom_Danger_0`
|
||||
* `Bottom_Warning_0`
|
||||
* `Bottom_Info_0`
|
||||
* `Bottom_Light_0`
|
||||
* `Bottom_Dark_0`
|
||||
* `Bottom_White_0`
|
||||
@ -0,0 +1,25 @@
|
||||
# 面包屑
|
||||
|
||||
## Introduction
|
||||
|
||||
`ABP-breadcrumb` 是面包屑项主容器.
|
||||
|
||||
基本用法:
|
||||
|
||||
````csharp
|
||||
<abp-breadcrumb>
|
||||
<abp-breadcrumb-item href="#" title="Home" />
|
||||
<abp-breadcrumb-item href="#" title="Library"/>
|
||||
<abp-breadcrumb-item title="Page"/>
|
||||
</abp-breadcrumb>
|
||||
````
|
||||
|
||||
## Demo
|
||||
|
||||
参阅[面包屑demo页面](https://bootstrap-taghelpers.abp.io/Components/Breadcrumbs)查看示例.
|
||||
|
||||
## abp-breadcrumb-item Attributes
|
||||
|
||||
- **title**: 设置面包屑项文本.
|
||||
- **active**: 设置活动面包屑项. 如果没有其他项是活动的,默认最后一项为活动项.
|
||||
- **href**: 表示 `abp-breadcrumb-item` 是否有链接. 值应该是字符串链接.
|
||||
@ -0,0 +1,114 @@
|
||||
# 导航
|
||||
|
||||
## 介绍
|
||||
|
||||
`abp-nav` 是从bootstrap nav元素派生的基本标签助手.
|
||||
|
||||
基本用法:
|
||||
|
||||
````csharp
|
||||
<abp-nav nav-style="Pill" align="Center">
|
||||
<abp-nav-item>
|
||||
<a abp-nav-link active="true" href="#">Active</a>
|
||||
</abp-nav-item>
|
||||
<abp-nav-item>
|
||||
<a abp-nav-link href="#">Longer nav link</a>
|
||||
</abp-nav-item>
|
||||
<abp-nav-item>
|
||||
<a abp-nav-link href="#">link</a>
|
||||
</abp-nav-item>
|
||||
<abp-nav-item>
|
||||
<a abp-nav-link disabled="true" href="#">disabled</a>
|
||||
</abp-nav-item>
|
||||
</abp-nav>
|
||||
````
|
||||
|
||||
## Demo
|
||||
|
||||
参阅[导航demo页面](https://bootstrap-taghelpers.abp.io/Components/Navs)查看示例.
|
||||
|
||||
## abp-nav Attributes
|
||||
|
||||
- **nav-style**: 指示包含项的位置和样式. 应为以下值之一:
|
||||
* `Default` (默认值)
|
||||
* `Vertical`
|
||||
* `Pill`
|
||||
* `PillVertical`
|
||||
- **align:** 指示包含项的对齐方式:
|
||||
* `Default` (默认值)
|
||||
* `Start`
|
||||
* `Center`
|
||||
* `End`
|
||||
|
||||
### abp-nav-bar Attributes
|
||||
|
||||
- **nav-style**: 指示基本导航栏的颜色布局. 应为以下值之一:
|
||||
* `Default` (默认值)
|
||||
* `Dark`
|
||||
* `Light`
|
||||
* `Dark_Primary`
|
||||
* `Dark_Secondary`
|
||||
* `Dark_Success`
|
||||
* `Dark_Danger`
|
||||
* `Dark_Warning`
|
||||
* `Dark_Info`
|
||||
* `Dark_Dark`
|
||||
* `Dark_Link`
|
||||
* `Light_Primary`
|
||||
* `Light_Secondary`
|
||||
* `Light_Success`
|
||||
* `Light_Danger`
|
||||
* `Light_Warning`
|
||||
* `Light_Info`
|
||||
* `Light_Dark`
|
||||
* `Light_Link`
|
||||
- **size:** 指示基本导航栏的大小. 应为以下值之一:
|
||||
* `Default` (默认值)
|
||||
* `Sm`
|
||||
* `Md`
|
||||
* `Lg`
|
||||
* `Xl`
|
||||
|
||||
### abp-nav-item Attributes
|
||||
|
||||
**dropdown**: 将导航项设置为下拉菜单(如果提供的话). 可以是下列值之一:
|
||||
|
||||
* `false` (默认值)
|
||||
* `true`
|
||||
|
||||
示例:
|
||||
|
||||
````csharp
|
||||
<abp-nav-bar size="Lg" navbar-style="Dark_Warning">
|
||||
<a abp-navbar-brand href="#">Navbar</a>
|
||||
<abp-navbar-toggle>
|
||||
<abp-navbar-nav>
|
||||
<abp-nav-item active="true">
|
||||
<a abp-nav-link href="#">Home <span class="sr-only">(current)</span></a>
|
||||
</abp-nav-item>
|
||||
<abp-nav-item>
|
||||
<a abp-nav-link href="#">Link</a>
|
||||
</abp-nav-item>
|
||||
<abp-nav-item dropdown="true">
|
||||
<abp-dropdown>
|
||||
<abp-dropdown-button nav-link="true" text="Dropdown" />
|
||||
<abp-dropdown-menu>
|
||||
<abp-dropdown-header>Dropdown header</abp-dropdown-header>
|
||||
<abp-dropdown-item href="#" active="true">Action</abp-dropdown-item>
|
||||
<abp-dropdown-item href="#" disabled="true">Another disabled action</abp-dropdown-item>
|
||||
<abp-dropdown-item href="#">Something else here</abp-dropdown-item>
|
||||
<abp-dropdown-divider />
|
||||
<abp-dropdown-item href="#">Separated link</abp-dropdown-item>
|
||||
</abp-dropdown-menu>
|
||||
</abp-dropdown>
|
||||
</abp-nav-item>
|
||||
<abp-nav-item>
|
||||
<a abp-nav-link disabled="true" href="#">Disabled</a>
|
||||
</abp-nav-item>
|
||||
</abp-navbar-nav>
|
||||
<span abp-navbar-text>
|
||||
Sample Text
|
||||
</span>
|
||||
</abp-navbar-toggle>
|
||||
</abp-nav-bar>
|
||||
````
|
||||
@ -0,0 +1,59 @@
|
||||
# 表格
|
||||
|
||||
## 介绍
|
||||
|
||||
`ABP-table` 在ABP中用于表格的基本标签组件.
|
||||
|
||||
基本用法:
|
||||
|
||||
````csharp
|
||||
<abp-table hoverable-rows="true" responsive-sm="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="Column">#</th>
|
||||
<th scope="Column">First</th>
|
||||
<th scope="Column">Last</th>
|
||||
<th scope="Column">Handle</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="Row">1</th>
|
||||
<td>Mark</td>
|
||||
<td>Otto</td>
|
||||
<td table-style="Danger">mdo</td>
|
||||
</tr>
|
||||
<tr table-style="Warning">
|
||||
<th scope="Row">2</th>
|
||||
<td>Jacob</td>
|
||||
<td>Thornton</td>
|
||||
<td>fat</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="Row">3</th>
|
||||
<td table-style="Success">Larry</td>
|
||||
<td>the Bird</td>
|
||||
<td>twitter</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</abp-table>
|
||||
````
|
||||
|
||||
## Demo
|
||||
|
||||
参阅[表格demo页面](https://bootstrap-taghelpers.abp.io/Components/Tables)查看示例.
|
||||
|
||||
## abp-table Attributes
|
||||
|
||||
- **responsive**: 用于创建直至特定断点的响应表. 请参阅[特定断点](https://getbootstrap.com/docs/4.1/content/tables/#breakpoint-specific)获取更多信息.
|
||||
- **responsive-sm**: 如果没有设置为false,则为小屏幕设备设置表响应性.
|
||||
- **responsive-md**: 如果未设置为false,则为中等屏幕设备设置表响应性.
|
||||
- **responsive-lg**: 如果未设置为false,则为大屏幕设备设置表响应性.
|
||||
- **responsive-xl**: 如果未设置为false,则为超大屏幕设备设置表响应性.
|
||||
- **dark-theme**: 如果设置为true,则将表格颜色主题设置为黑暗.
|
||||
- **striped-rows**: 如果设置为true,则将斑马条纹添加到表行中.
|
||||
- **hoverable-rows**: 如果设置为true,则将悬停状态添加到表行.
|
||||
- **border-style**: 设置表格的边框样式. 应为以下值之一:
|
||||
- `Default` (默认)
|
||||
- `Bordered`
|
||||
- `Borderless`
|
||||
Loading…
Reference in new issue