Update document

pull/4301/head
liangshiwei 5 years ago
parent f87158eb23
commit 18d22c163c

@ -59,7 +59,7 @@ Here are the fundamental properties of the `ICurrentUser` interface:
* **UserName** (string): User name of the current user. Returns `null`, if the current user has not logged in.
* **TenantId** (Guid?): Tenant Id of the current user, which can be useful for a [multi-tenant](Multi-Tenancy.md) application. Returns `null`, if the current user is not assigned to a tenant.
* **Email** (string): Email address of the current user.Returns `null`, if the current user has not logged in or not set an email address.
* **EmailVerified** (bool): Returns `true`, if the phone number of the current user has been verified.
* **EmailVerified** (bool): Returns `true`, if the email address of the current user has been verified.
* **PhoneNumber** (string): Phone number of the current user. Returns `null`, if the current user has not logged in or not set a phone number.
* **PhoneNumberVerified** (bool): Returns `true`, if the phone number of the current user has been verified.
* **Roles** (string[]): Roles of the current user. Returns a string array of the role names of the current user.

@ -87,6 +87,7 @@ abp new Acme.BookStore
* `mongodb`: MongoDB.
* `module`: [Module template](Startup-Templates/Module.md). 其他选项:
* `--no-ui`: 不包含UI.仅创建服务模块(也称为微服务 - 没有UI).
* **`console`**: [Console template](Startup-Templates/Console.md).
* `--output-folder` 或者 `-o`: 指定输出文件夹,默认是当前目录.
* `--version` 或者 `-v`: 指定ABP和模板的版本.它可以是 [release tag](https://github.com/abpframework/abp/releases) 或者 [branch name](https://github.com/abpframework/abp/branches). 如果没有指定,则使用最新版本.大多数情况下,你会希望使用最新的版本.
* `--template-source` 或者 `-ts`: 指定自定义模板源用于生成项目,可以使用本地源和网络源(例如 `D\localTemplate``https://<your url>.zip`).

@ -73,8 +73,18 @@ public class IdentityServerDbContext
启动模板(使用 EF Core ORM) 带有一个数据库和一个 `.EntityFrameworkCore.DbMigrations` 项目,其中包含数据库的迁移文件. 该项目主要定义了一个*YourProjectName*MigrationsDbContext,它调用所有模块的 `Configure...()` 方法,例如 `builder.ConfigurePermissionManagement()`.
一旦要分离模块的数据库,通常需要创建第二个迁移路径. 最简单的方法是创建一个带有 `DbContext``.EntityFrameworkCore.DbMigrations` 项目副本, 更改为只调用需要存储在第二个数据库中的模块的 `Configure...()` 方法并重新创建迁移. 这时你还需要更改 `.DbMigrator` 应用程序使其兼容第二个数据库,这样每个数据库将有一个单独的迁移DbContext.
一旦要分离模块的数据库,通常需要创建第二个迁移路径. 请参阅[EF Core迁移文档](Entity-Framework-Core-Migrations.md)了解如何为所需模块创建和使用其他数据库.
## 多租户
参阅 [多租户文档](Multi-Tenancy.md)了解如何为租户使用单独的数据库.
参阅 [多租户文档](Multi-Tenancy.md)了解如何为租户使用单独的数据库.
## 替换连接字符串解析器
ABP定义了 `IConnectionStringResolver`,并在需要连接字符串时使用它. 有两个预构建的实现:
* `DefaultConnectionStringResolver` 根据上面"配置连接字符串"一节中定义的规则,使用 `AbpDbConnectionOptions` 选择连接字符串.
* `MultiTenantConnectionStringResolver` used for multi-tenant applications and tries to get the configured connection string for the current tenant if available. It uses the `ITenantStore` to find the connection strings. It inherits from the `DefaultConnectionStringResolver` and fallbacks to the base logic if no connection string specified for the current tenant.
* `MultiTenantConnectionStringResolver` 用于多租户应用程序,并尝试获取当前租户的已配置连接字符串(如果有). 它使用 `ITenantStore` 查找连接字符串. 它继承了 `DefaultConnectionStringResolver`, 如果没有为当前租户指定连接字符串则回退到基本逻辑.
如果需要自定义逻辑来确定连接字符串,可以实现 `IConnectionStringResolver` 接口(也可以从现有类派生)并使用[依赖注入](Dependency-Injection.md)系统替换现有实现.

@ -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框架通过尽可能遵循标准名称来定义的.
建议使用这个类的属性来代替声明名称的魔术字符串.

@ -10,8 +10,8 @@ ABP是一个**开源应用程序框架**,专注于基于ASP.NET Core的Web应用
使用ABP开发新项目的最简单方法是使用启动模板:
* [ASP.NET Core MVC (Razor Pages) UI 启动模板](Getting-Started?UI=MVC&DB=EF&Tiered=No)
* [Angular UI 启动模板](Getting-Started?UI=NG&DB=EF&Tiered=No)
* [ASP.NET Core MVC (Razor Pages) UI 启动模板](Getting-Started.md?UI=MVC&DB=EF&Tiered=No)
* [Angular UI 启动模板](Getting-Started.md?UI=NG&DB=EF&Tiered=No)
如果你想从头开始(使用空项目),请手动安装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*. 你可以使用单级或多级名称.

@ -5,4 +5,5 @@
单击下面列表中的名称以查看相关启动模板的文档:
* [**app**](Application.md): 应用程序模板.
* [**module**](Module.md): 模块/服务模板.
* [**module**](Module.md): 模块/服务模板.
* [**console**](Console.md): 控制台模板.

@ -543,6 +543,10 @@ export class AppComponent implements OnInit {
![New nav-items](./images/replaced-nav-items-component.png)
## 另请参阅
- [如何替换PermissionManagementComponent](./Permission-Management-Component-Replacement.md)
## 下一步是什么?
- [自定义设置页面](./Custom-Setting-Page.md)

@ -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`

@ -181,6 +181,36 @@
"path": "Object-To-Object-Mapping.md"
},
{
"text": "BLOB存储",
"items": [
{
"text": "BLOB存储系统",
"path": "Blob-Storing.md"
},
{
"text": "存储提供者",
"items": [
{
"text": "文件系统提供者",
"path": "Blob-Storing-File-System.md"
},
{
"text": "数据库系统提供者",
"path": "Blob-Storing-Database.md"
},
{
"text": "Azure提供者",
"path": "Blob-Storing-Azure.md"
},
{
"text": "创建自定义提供者",
"path": "Blob-Storing-Custom-Provider.md"
}
]
}
]
},
{
"text": "文本模板",
"path": "Text-Templating.md"

Loading…
Cancel
Save