Browse Source

Update document

pull/3669/head
liangshiwei 6 years ago
parent
commit
f898af05a4
  1. 2
      docs/en/Exception-Handling.md
  2. 2
      docs/zh-Hans/Customizing-Application-Modules-Extending-Entities.md
  3. 4
      docs/zh-Hans/Exception-Handling.md
  4. 44
      docs/zh-Hans/Startup-Templates/Application.md
  5. 3
      docs/zh-Hans/UI/Angular/AddingSettingTab.md
  6. 293
      docs/zh-Hans/UI/Angular/Config-State.md
  7. BIN
      docs/zh-Hans/images/bookstore-home.png
  8. BIN
      docs/zh-Hans/images/bookstore-login.png
  9. BIN
      docs/zh-Hans/images/db-migrator-output.png
  10. BIN
      docs/zh-Hans/images/package-manager-console-update-database.png
  11. BIN
      docs/zh-Hans/images/rn-environment-local-ip.png
  12. BIN
      docs/zh-Hans/images/rn-expo-interface.png
  13. BIN
      docs/zh-Hans/images/rn-host-local-ip.png
  14. BIN
      docs/zh-Hans/images/rn-login-iphone.png
  15. BIN
      docs/zh-Hans/images/rn-tiered-local-ip.png
  16. BIN
      docs/zh-Hans/images/solution-files-mvc.png
  17. BIN
      docs/zh-Hans/images/solution-files-non-mvc.png
  18. BIN
      docs/zh-Hans/images/swagger-ui.png
  19. BIN
      docs/zh-Hans/images/vs-app-solution-structure-mongodb.png
  20. BIN
      docs/zh-Hans/images/vs-app-solution-structure-tiered.png
  21. BIN
      docs/zh-Hans/images/vs-app-solution-structure.png
  22. BIN
      docs/zh-Hans/images/vs-spa-app-backend-structure-mongodb.png
  23. BIN
      docs/zh-Hans/images/vs-spa-app-backend-structure.png

2
docs/en/Exception-Handling.md

@ -316,7 +316,7 @@ The `context` object contains necessary information about the exception occurred
Some exception types are automatically thrown by the framework:
- `AbpAuthorizationException` is thrown if the current user has no permission to perform the requested operation. See [authorization](Authorization.md) for more.
- `AbpValidationException` is thrown if the input of the current request is not valid. See [validation] (Validation.md) for more.
- `AbpValidationException` is thrown if the input of the current request is not valid. See [validation](Validation.md) for more.
- `EntityNotFoundException` is thrown if the requested entity is not available. This is mostly thrown by [repositories](Repositories.md).
You can also throw these type of exceptions in your code (although it's rarely needed).

2
docs/zh-Hans/Customizing-Application-Modules-Extending-Entities.md

@ -50,7 +50,7 @@ ObjectExtensionManager.Instance
* 你提供了 `IdentityUser` 作为实体名(泛型参数), `string` 做为新属性的类型, `SocialSecurityNumber` 做为属性名(也是数据库表的字段名).
* 你还需要提供一个使用[EF Core Fluent API](https://docs.microsoft.com/en-us/ef/core/modeling/entity-properties)定义数据库映射属性的操作.
> 必须在使用相关的 `DbContext` 之前执行此代码. 应用程序启动模板定义了一个名为 `YourProjectNameEntityExtensions` 的静态类. 你可以在此类中定义扩展确保在正确的时间执行它. 否则你需要自己处理.
> 必须在使用相关的 `DbContext` 之前执行此代码. 应用程序启动模板定义了一个名为 `YourProjectNameEfCoreEntityExtensionMappings` 的静态类. 你可以在此类中定义扩展确保在正确的时间执行它. 否则你需要自己处理.
定义实体扩展后你需要使用EF Core的[Add-Migration](https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell#add-migration)和[Update-Database](https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell#update-database)命令来创建code first迁移类并更新数据库.

4
docs/zh-Hans/Exception-Handling.md

@ -295,8 +295,8 @@ services.Configure<AbpExceptionHttpStatusCodeOptions>(options =>
框架会自动抛出以下异常类型:
- 当用户没有权限执行操作时,会抛出 `AbpAuthorizationException` 异常. 有关更多信息,请参阅授权文档(TODO:link).
- 如果当前请求的输入无效,则抛出`AbpValidationException 异常`. 有关更多信息,请参阅授权文档(TODO:link).
- 当用户没有权限执行操作时,会抛出 `AbpAuthorizationException` 异常. 有关更多信息,请参阅授权文档[authorization](Authorization.md).
- 如果当前请求的输入无效,则抛出`AbpValidationException 异常`. 有关更多信息,请参阅[验证文档](Validation.md).
- 如果请求的实体不存在,则抛出`EntityNotFoundException` 异常. 此异常大多数由 [repositories](Repositories.md) 抛出.
你同样可以在代码中抛出这些类型的异常(虽然很少需要这样做)

44
docs/zh-Hans/Startup-Templates/Application.md

@ -362,7 +362,7 @@ React Native 应用文件夹结构, 如下图所示:
#### Components(组件)
可以在所有屏幕上使用的组件是在 `src/components` 文件夹中创建的. 所有组件都是作为一个能够使用 [hooks](https://reactjs.org/docs/hooks-intro.html) 的函数创建的.
可以在所有屏幕上使用的组件是在 `src/components` 文件夹中创建的. 所有组件都是作为一个能够使用 [hooks](https://reactjs.org/docs/hooks-intro.html) 的函数创建的.
#### Screens(屏幕)
@ -378,7 +378,7 @@ Screens 是通过在 `src/screens` 文件夹中创建将名称分开的文件夹
#### State Management(状态管理)
[Redux](https://redux.js.org/) 被用作状态管理库. [Redux Toolkit](https://redux-toolkit.js.org/) 库被用作高效Redux开发的工具集.
[Redux](https://redux.js.org/) 被用作状态管理库. [Redux Toolkit](https://redux-toolkit.js.org/) 库被用作高效Redux开发的工具集.
`src/store` 文件夹中创建 Actions, reducers, sagas, selectors. 存储文件夹如下:
@ -387,41 +387,41 @@ Screens 是通过在 `src/screens` 文件夹中创建将名称分开的文件夹
* [**Store**](https://redux.js.org/basics/store) 在 `src/store/index.js` 文件中定义.
* [**Actions**](https://redux.js.org/basics/actions/) 是将数据从应用程序发送到存储的有效信息负载.
* [**Reducers**](https://redux.js.org/basics/reducers) 指定应用程序的状态如何更改以响应发送到存储的操作.
* [**Redux-Saga**](https://redux-saga.js.org/) 是一个库, 旨在使应用程序的副作用(即异步的事情, 如数据获取和不纯的事情, 如访问浏览器缓存)更容易管理. Sagas 是在 `src/store/sagas` 文件夹中创建的.
* [**Redux-Saga**](https://redux-saga.js.org/) 是一个库, 旨在使应用程序的副作用(即异步的事情, 如数据获取和不纯的事情, 如访问浏览器缓存)更容易管理. Sagas 是在 `src/store/sagas` 文件夹中创建的.
* [**Reselect**](https://github.com/reduxjs/reselect) 库用于创建缓存的选择器. 选择器是在 `src/store/selectors` 文件夹中创建的.
#### APIs
[Axios](https://github.com/axios/axios) 用作HTTP客户端库. Axios 实例从 `src/api/API.js` 导出 . 使用相同的配置进行HTTP调用. `src/api` 文件夹中还有为 API 调用创建的 API 文件.
[Axios](https://github.com/axios/axios) 用作HTTP客户端库. Axios 实例从 `src/api/API.js` 导出 . 使用相同的配置进行HTTP调用. `src/api` 文件夹中还有为 API 调用创建的 API 文件.
#### Theming(主题)
[Native Base](https://nativebase.io/) 被用作UI组件库. 本地基本组件可以很容易地进行自定义。参见 [Native Base customize](https://docs.nativebase.io/Customize.html#Customize) 文档。我们沿着同样的路走。
[Native Base](https://nativebase.io/) 被用作UI组件库. 本地基本组件可以很容易地进行自定义.参见[Native Base customize](https://docs.nativebase.io/Customize.html#Customize) 文档.我们沿着同样的路走.
* Native Base 主题变量在 `src/theme/variables` 文件夹中
* Native Base 组件样式在 `src/theme/components` 文件夹中。这些文件是用 Native Base's `ejectTheme` 脚本生成的。
* 组件样式用 `src/theme/overrides` 文件夹下的文件覆盖
* Native Base 主题变量在 `src/theme/variables` 文件夹中.
* Native Base 组件样式在 `src/theme/components` 文件夹中.这些文件是用 Native Base's `ejectTheme` 脚本生成的.
* 组件样式用 `src/theme/overrides` 文件夹下的文件覆盖.
#### Testing(单元测试)
将创建单元测试
将创建单元测试.
参见[测试概述](https://reactjs.org/docs/testing.html)文档
参见[测试概述](https://reactjs.org/docs/testing.html)文档.
#### Depended Libraries(依赖库)
* [Native Base](https://nativebase.io/) 用作UI组件库
* [React Navigation](https://reactnavigation.org/) 用作导航库
* [Axios](https://github.com/axios/axios) 用作HTTP客户端库
* [Redux](https://redux.js.org/) 用作状态管理库
* [Redux Toolkit](https://redux-toolkit.js.org/) 库被用作高效Redux开发的工具集
* [Redux-Saga](https://redux-saga.js.org/) 用于管理异步进程
* [Redux Persist](https://github.com/rt2zz/redux-persist) 被用作状态持久化
* [Reselect](https://github.com/reduxjs/reselect) 用于创建缓存的选择器
* [i18n-js](https://github.com/fnando/i18n-js) 作为国际化库使用
* [expo-font](https://docs.expo.io/versions/latest/sdk/font/) 库可以轻松加载字体
* [Formik](https://github.com/jaredpalmer/formik) 用于构建表单
* [Yup](https://github.com/jquense/yup) 用于表单验证
* [Native Base](https://nativebase.io/) 用作UI组件库.
* [React Navigation](https://reactnavigation.org/) 用作导航库.
* [Axios](https://github.com/axios/axios) 用作HTTP客户端库.
* [Redux](https://redux.js.org/) 用作状态管理库.
* [Redux Toolkit](https://redux-toolkit.js.org/) 库被用作高效Redux开发的工具集.
* [Redux-Saga](https://redux-saga.js.org/) 用于管理异步进程.
* [Redux Persist](https://github.com/rt2zz/redux-persist) 被用作状态持久化.
* [Reselect](https://github.com/reduxjs/reselect) 用于创建缓存的选择器.
* [i18n-js](https://github.com/fnando/i18n-js) 作为国际化库使用.
* [expo-font](https://docs.expo.io/versions/latest/sdk/font/) 库可以轻松加载字体.
* [Formik](https://github.com/jaredpalmer/formik) 用于构建表单.
* [Yup](https://github.com/jquense/yup) 用于表单验证.
## 下一步是什么?

3
docs/zh-Hans/UI/Angular/AddingSettingTab.md

@ -1,3 +0,0 @@
## Creating a Settings Tab
TODO...

293
docs/zh-Hans/UI/Angular/Config-State.md

@ -1,3 +1,294 @@
## 配置状态
TODO...
`ConfigStateService` 是一个单例服务,即在应用程序的根级别提供,用于与 `Store` 中的应用程序配置状态进行交互.
## 使用前
为了使用 `ConfigStateService`,你必须将其注入到你的类中.
```js
import { ConfigStateService } from '@abp/ng.core';
@Component({
/* class metadata here */
})
class DemoComponent {
constructor(private config: ConfigStateService) {}
}
```
你不必在模块或组件/指令级别提供 `ConfigStateService`,因为它已经在**根中**提供.
## 选择器方法
`ConfigStateService` 有许多选择器方法允许你从 `Store` 获取特定或所有的配置.
### 如何从Store获取所有的配置
你可以使用 `ConfigStateService``getAll` 方法从Store获取所有的配置对象. 用法如下:
```js
// this.config is instance of ConfigStateService
const config = this.config.getAll();
```
### 如何从Store获取特定的配置
你可以使用 `ConfigStateService``getOne` 方法从Store获取特定的配置属性. 你需要将属性名做为参数传递给方法:
```js
// this.config is instance of ConfigStateService
const currentUser = this.config.getOne("currentUser");
```
有时你想要获取具体信息,而不是当前用户. 例如你只想获取到 `tenantId`:
```js
const tenantId = this.config.getDeep("currentUser.tenantId");
```
或通过提供键数组作为参数:
```js
const tenantId = this.config.getDeep(["currentUser", "tenantId"]);
```
`getDeep` 可以执行 `getOne` 的所有操作. 但 `getOne` 的执行效率要高一些.
#### 配置状态属性
请参阅 `Config.State` 类型,你可以通过 `getOne``getDeep` 获取所有属性. 你可以在[config.ts 文件](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L7)中找到.
### 如何从Store获取应用程序信息
`getApplicationInfo` 方法从存储为配置状态存储的环境变量中获取应用程序信息. 你可以这样使用它:
```js
// this.config is instance of ConfigStateService
const appInfo = this.config.getApplicationInfo();
```
该方法不会返回 `undefined``null`,而是会返回一个空对象(`{}`). 换句话说,当你使用上面代码中的 `appInfo` 属性时,永远不会出现错误.
#### 应用程序信息属性
请参阅 `Config.State` 类型,你可以通过 `getApplicationInfo` 获取所有属性. 你可以在[config.ts 文件](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L21)中找到.
### 如何从Store获取
`getApplicationInfo` 方法从存储为配置状态存储的环境变量中获取特定的API URL. 你可以这样使用它:
```js
// this.config is instance of ConfigStateService
const apiUrl = this.config.getApiUrl();
// environment.apis.default.url
const searchUrl = this.config.getApiUrl("search");
// environment.apis.search.url
```
该方法返回给定键的特定的API `url`. 如果没有Key,则使用 `default`.
### 如何从Store获取所有的设置
你可以使用 `ConfigStateService``getSettings` 获取配置状态所有的设置对象. 你可以这样使用它:
```js
// this.config is instance of ConfigStateService
const settings = this.config.getSettings();
```
实际上该方法可以通过**传递关键字**来搜索设置.
```js
const localizationSettings = this.config.getSettings("Localization");
/*
{
'Abp.Localization.DefaultLanguage': 'en'
}
*/
```
请注意, **设置搜索区分大小写**.
### 如何从Store获取特定的设置
你可以使用 `ConfigStateService``getSetting` 获取配置状态特定的设置. 你可以这样使用它:
```js
// this.config is instance of ConfigStateService
const defaultLang = this.config.getSetting("Abp.Localization.DefaultLanguage");
// 'en'
```
### 如何从Store获取特定的权限
你可以使用 `ConfigStateService``getGrantedPolicy` 获取配置状态特定的权限. 你应该将策略key做为参数传递给方法:
```js
// this.config is instance of ConfigStateService
const hasIdentityPermission = this.config.getGrantedPolicy("Abp.Identity");
// true
```
你还可以使用 **组合策略key** 来微调你的选择:
```js
// this.config is instance of ConfigStateService
const hasIdentityAndAccountPermission = this.config.getGrantedPolicy(
"Abp.Identity && Abp.Account"
);
// false
const hasIdentityOrAccountPermission = this.config.getGrantedPolicy(
"Abp.Identity || Abp.Account"
);
// true
```
创建权限选择器时,请考虑以下**规则**:
- 最多可组合两个键.
- `&&` 操作符查找两个键.
- `||` 操作符查找任意一个键.
- 空字符串 `''` 做为键将返回 `true`
- 使用没有第二个键的操作符将返回 `false`
### 如何从Store中获取翻译
`ConfigStateService``getLocalization` 用法翻译. 这里有一些示例:
```js
// this.config is instance of ConfigStateService
const identity = this.config.getLocalization("AbpIdentity::Identity");
// 'identity'
const notFound = this.config.getLocalization("AbpIdentity::IDENTITY");
// 'AbpIdentity::IDENTITY'
const defaultValue = this.config.getLocalization({
key: "AbpIdentity::IDENTITY",
defaultValue: "IDENTITY"
});
// 'IDENTITY'
```
请参阅[本地化文档](./Localization.md)了解详情.
## 分发方法
`ConfigStateService` 有几种分发方法,让你方便地将预定义操作分发到 `Store`.
### 如何从服务器获取应用程序配置
`dispatchGetAppConfiguration` 触发对端点的请求,该端点使用应用程序状态进行响应,然后将此响应作为配置状态放置到 `Store`中.
```js
// this.config is instance of ConfigStateService
this.config.dispatchGetAppConfiguration();
// returns a state stream which emits after dispatch action is complete
```
请注意,**你不必在应用程序启动时调用此方法**,因为在启动时已经从服务器收到了应用程序配置.
### 如何修补路由配置
`dispatchPatchRouteByName` 根据名称查找路由, 并将其在 `Store` 中的配置替换为作为第二个参数传递的新配置.
```js
// this.config is instance of ConfigStateService
const newRouteConfig: Partial<ABP.Route> = {
name: "Home",
path: "home",
children: [
{
name: "Dashboard",
path: "dashboard"
}
]
};
this.config.dispatchPatchRouteByName("::Menu:Home", newRouteConfig);
// returns a state stream which emits after dispatch action is complete
```
### 如何添加新路由配置
`dispatchAddRoute``Store` 的配置状态添加一个新路由. 应该将路由配置做为方法参数传递.
```js
// this.config is instance of ConfigStateService
const newRoute: ABP.Route = {
name: "My New Page",
iconClass: "fa fa-dashboard",
path: "page",
invisible: false,
order: 2,
requiredPolicy: "MyProjectName::MyNewPage"
};
this.config.dispatchAddRoute(newRoute);
// returns a state stream which emits after dispatch action is complete
```
`newRoute` 将被放置在根级别,没有任何父路由,并且其url将存储为 `'/path'`.
如果你想要**添加一个子路由,您可以这样做:**
```js
// this.config is instance of ConfigStateService
const newRoute: ABP.Route = {
parentName: "AbpAccount::Login",
name: "My New Page",
iconClass: "fa fa-dashboard",
path: "page",
invisible: false,
order: 2,
requiredPolicy: "MyProjectName::MyNewPage"
};
this.config.dispatchAddRoute(newRoute);
// returns a state stream which emits after dispatch action is complete
```
`newRoute` 做为 `'AbpAccount::Login'` 父路由的子路由被放置,它的url被设置为 `'/account/login/page'`.
#### 路由配置属性
请参阅 `ABP.Route` 类型,获取可在参数中传递给 `dispatchSetEnvironment` 的所有属性. 你可以在[common.ts 文件](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/common.ts#L27)中找到.
### 如何设置环境
`dispatchSetEnvironment` 将传递给它的环境变量放在 `Store` 中的配置状态下. 使用方法如下:
```js
// this.config is instance of ConfigStateService
this.config.dispatchSetEnvironment({
/* environment properties here */
});
// returns a state stream which emits after dispatch action is complete
```
注意,**你不必在应用程序启动时调用此方法**,因为环境变量已经在启动时存储了.
#### 环境属性
请参阅 `Config.Environment` 类型,获取可在参数中传递给 `dispatchSetEnvironment` 的所有属性. 你可以在[config.ts 文件](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L13)中找到.
## 下一步是什么?
* [组件替换]](./Component-Replacement.md)

BIN
docs/zh-Hans/images/bookstore-home.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
docs/zh-Hans/images/bookstore-login.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
docs/zh-Hans/images/db-migrator-output.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
docs/zh-Hans/images/package-manager-console-update-database.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
docs/zh-Hans/images/rn-environment-local-ip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
docs/zh-Hans/images/rn-expo-interface.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
docs/zh-Hans/images/rn-host-local-ip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

BIN
docs/zh-Hans/images/rn-login-iphone.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
docs/zh-Hans/images/rn-tiered-local-ip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

BIN
docs/zh-Hans/images/solution-files-mvc.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

BIN
docs/zh-Hans/images/solution-files-non-mvc.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
docs/zh-Hans/images/swagger-ui.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
docs/zh-Hans/images/vs-app-solution-structure-mongodb.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

BIN
docs/zh-Hans/images/vs-app-solution-structure-tiered.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 KiB

BIN
docs/zh-Hans/images/vs-app-solution-structure.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

BIN
docs/zh-Hans/images/vs-spa-app-backend-structure-mongodb.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

BIN
docs/zh-Hans/images/vs-spa-app-backend-structure.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

Loading…
Cancel
Save