From 10694d96f2efc9e487de5572f11378a08ad360be Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 11 Mar 2020 20:06:13 +0800 Subject: [PATCH] Update docs.md --- docs/en/Modules/Docs.md | 88 ++++++++++++++++++++++-------------- docs/zh-Hans/Modules/Docs.md | 75 ++++++++++++++++++------------ 2 files changed, 100 insertions(+), 63 deletions(-) diff --git a/docs/en/Modules/Docs.md b/docs/en/Modules/Docs.md index 03ab20557c..0c0a221569 100644 --- a/docs/en/Modules/Docs.md +++ b/docs/en/Modules/Docs.md @@ -38,7 +38,7 @@ Note that this document covers `Entity Framework Core` provider but you can also ### 2- Running The Empty Application -After you download the project, extract the ZIP file and open `Acme.MyProject.sln`. You will see that the solution consists of `Application`, `Application.Contrawcts`, `DbMigrator`, `Domain`, `Domain.Shared`, `EntityFrameworkCore`, `EntityFrameworkCore.DbMigations`, `HttpApi`, `HttpApi.Client` and `Web` projects. Right click on `Acme.MyProject.Web` project and **Set as StartUp Project**. +After you download the project, extract the ZIP file and open `Acme.MyProject.sln`. You will see that the solution consists of `Application`, `Application.Contracts`, `DbMigrator`, `Domain`, `Domain.Shared`, `EntityFrameworkCore`, `EntityFrameworkCore.DbMigations`, `HttpApi`, `HttpApi.Client` and `Web` projects. Right click on `Acme.MyProject.Web` project and **Set as StartUp Project**. ![Create a new project](../images/docs-module_solution-explorer.png) @@ -62,21 +62,27 @@ To login your website enter `admin` as the username and `1q2w3E*` as the passwor Docs module packages are hosted on NuGet. There are 4 packages that needs be to installed to your application. Each package has to be installed to the relevant project. -Install [Volo.Docs.Domain](https://www.nuget.org/packages/Volo.Docs.Domain/) nuget package to `Acme.MyProject.Domain` project. +It is recommended to use the ABP CLI to install the module, open the CMD window in the solution file (`.sln`) directory, and run the following command: -`Install-Package Volo.Docs.Domain` +`abp add-module Volo.Docs` -Install [Volo.Docs.EntityFrameworkCore](https://www.nuget.org/packages/Volo.Docs.EntityFrameworkCore/) nuget package to `Acme.MyProject.EntityFrameworkCore` project. +Or you can also manually install nuget package to each project: -`Install-Package Volo.Docs.EntityFrameworkCore` +* Install [Volo.Docs.Domain](https://www.nuget.org/packages/Volo.Docs.Domain/) nuget package to `Acme.MyProject.Domain` project. -Install [Volo.Docs.Application](https://www.nuget.org/packages/Volo.Docs.Application/) nuget package to `Acme.MyProject.Application` project. + `Install-Package Volo.Docs.Domain` -`Install-Package Volo.Docs.Application` +* Install [Volo.Docs.EntityFrameworkCore](https://www.nuget.org/packages/Volo.Docs.EntityFrameworkCore/) nuget package to `Acme.MyProject.EntityFrameworkCore` project. -Install [Volo.Docs.Web](https://www.nuget.org/packages/Volo.Docs.Domain/) nuget package to `Acme.MyProject.Web` project. + `Install-Package Volo.Docs.EntityFrameworkCore` -`Install-Package Volo.Docs.Web` +* Install [Volo.Docs.Application](https://www.nuget.org/packages/Volo.Docs.Application/) nuget package to `Acme.MyProject.Application` project. + + `Install-Package Volo.Docs.Application` + +* Install [Volo.Docs.Web](https://www.nuget.org/packages/Volo.Docs.Domain/) nuget package to `Acme.MyProject.Web` project. + + `Install-Package Volo.Docs.Web` ### 3- Adding Module Dependencies @@ -165,33 +171,45 @@ An ABP module must declare `[DependsOn]` attribute if it has a dependency upon a If you choose Entity Framework as your database provider, you need to configure the Docs Module. To do this; -- Open `QaDocDbContextModelCreatingExtensions.cs` and add `modelBuilder.ConfigureDocs()` to the `ConfigureMyProject()`. +- Open `MyProjectMigrationsDbContext.cs` and add `builder.ConfigureDocs()` to the `OnModelCreating()`. ```csharp - public static class QaDocDbContextModelCreatingExtensions - { - public static void ConfigureMyProject(this ModelBuilder builder) - { - Check.NotNull(builder, nameof(builder)); - - /* Configure your own tables/entities inside here */ - - //builder.Entity(b => - //{ - // b.ToTable(QaDocConsts.DbTablePrefix + "YourEntities", QaDocConsts.DbSchema); - - // //... - //}); - - builder.ConfigureDocs(); - } - - public static void ConfigureCustomUserProperties(this EntityTypeBuilder b) - where TUser: class, IUser - { - //b.Property(nameof(AppUser.MyProperty))... - } - } + public class MyProjectMigrationsDbContext : AbpDbContext + { + public MyProjectMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + /* Include modules to your migration db context */ + + builder.ConfigurePermissionManagement(); + builder.ConfigureSettingManagement(); + builder.ConfigureBackgroundJobs(); + builder.ConfigureAuditLogging(); + builder.ConfigureIdentity(); + builder.ConfigureIdentityServer(); + builder.ConfigureFeatureManagement(); + builder.ConfigureTenantManagement(); + builder.ConfigureDocs(); //Add this line to configure the Docs Module + + /* Configure customizations for entities from the modules included */ + + builder.Entity(b => + { + b.ConfigureCustomUserProperties(); + }); + + /* Configure your own tables/entities inside the ConfigureQaDoc method */ + + builder.ConfigureMyProject(); + } + } ``` * Open `Package Manager Console` in `Visual Studio` and choose `Acme.MyProject.EntityFrameworkCore.DbMigrations` as default project. Then write the below command to add the migration for Docs Module. @@ -310,7 +328,7 @@ You can use [ABP Framework](https://github.com/abpframework/abp/) GitHub documen Note that `GitHubAccessToken` is masked with `***`. It's a private token that you must get it from GitHub. See https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ -- MainWebsiteUrl: `/` +- MainWebsiteUrl: `/` - LatestVersionBranchName: `master` diff --git a/docs/zh-Hans/Modules/Docs.md b/docs/zh-Hans/Modules/Docs.md index f10acf4d2f..a339730f49 100644 --- a/docs/zh-Hans/Modules/Docs.md +++ b/docs/zh-Hans/Modules/Docs.md @@ -60,21 +60,28 @@ ABP框架的[文档](docs.abp.io)也是使用的此模块. ### 2- 引用文档模块包 -文档模块包托管在Nuget上面. 需要有四个包安装到你的应用程序中. 每个包必须安装到相关的项目. +文档模块包托管在Nuget上面. 需要有四个包安装到你的应用程序中. 每个包必须安装到相关的项目. -安装[Volo.Docs.Domain](https://www.nuget.org/packages/Volo.Docs.Domain/) nuget包到 `Acme.MyProject.Domain` 项目. +建议使用ABP CLI安装模块,在解决方案文件 (`.sln`) 目录打开 `CMD` 窗口,运行以下命令: -`Install-Package Volo.Docs.Domain` +`abp add-module Volo.Docs` -安装[Volo.Docs.EntityFrameworkCore](https://www.nuget.org/packages/Volo.Docs.EntityFrameworkCore/) nuget包到 `Acme.MyProject.EntityFrameworkCore` 项目. +或者你也可以手动安装nuget包到每个项目: -`Install-Package Volo.Docs.EntityFrameworkCore` +* 安装[Volo.Docs.Domain](https://www.nuget.org/packages/Volo.Docs.Domain/) nuget包到 `Acme.MyProject.Domain` 项目. -安装[Volo.Docs.Application](https://www.nuget.org/packages/Volo.Docs.Application/) nuget包到 `Acme.MyProject.Application` 项目. + `Install-Package Volo.Docs.Domain` -`Install-Package Volo.Docs.Application` +* 安装[Volo.Docs.EntityFrameworkCore](https://www.nuget.org/packages/Volo.Docs.EntityFrameworkCore/) nuget包到 `Acme.MyProject.EntityFrameworkCore` 项目. -安装[Volo.Docs.Web](https://www.nuget.org/packages/Volo.Docs.Domain/) nuget包到 `Acme.MyProject.Web` 项目. + `Install-Package Volo.Docs.EntityFrameworkCore` + +* 安装[Volo.Docs.Application](https://www.nuget.org/packages/Volo.Docs.Application/) nuget包到 `Acme.MyProject.Application` 项目. + + `Install-Package Volo.Docs.Application` + +* 安装[Volo.Docs.Web](https://www.nuget.org/packages/Volo.Docs.Domain/) nuget包到 `Acme.MyProject.Web` 项目. + `Install-Package Volo.Docs.Web` ### 3- 添加模块依赖 @@ -164,33 +171,45 @@ ABP框架的[文档](docs.abp.io)也是使用的此模块. 如果你选择了Entity Framework 做为数据库供应者,你需要配置文档模块. 做以下操作; -* 打开 `QaDocDbContextModelCreatingExtensions.cs` 并且添加 `modelBuilder.ConfigureDocs()` 到 `ConfigureMyProject()` 方法中 +* 打开 `MyProjectMigrationsDbContext.cs` 并且添加 `builder.ConfigureDocs()` 到 `OnModelCreating()` 方法中 ```csharp - public static class QaDocDbContextModelCreatingExtensions - { - public static void ConfigureMyProject(this ModelBuilder builder) - { - Check.NotNull(builder, nameof(builder)); + public class MyProjectMigrationsDbContext : AbpDbContext + { + public MyProjectMigrationsDbContext(DbContextOptions options) + : base(options) + { - /* Configure your own tables/entities inside here */ + } - //builder.Entity(b => - //{ - // b.ToTable(QaDocConsts.DbTablePrefix + "YourEntities", QaDocConsts.DbSchema); + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); - // //... - //}); + /* Include modules to your migration db context */ - builder.ConfigureDocs(); - } + builder.ConfigurePermissionManagement(); + builder.ConfigureSettingManagement(); + builder.ConfigureBackgroundJobs(); + builder.ConfigureAuditLogging(); + builder.ConfigureIdentity(); + builder.ConfigureIdentityServer(); + builder.ConfigureFeatureManagement(); + builder.ConfigureTenantManagement(); + builder.ConfigureDocs(); //Add this line to configure the Docs Module - public static void ConfigureCustomUserProperties(this EntityTypeBuilder b) - where TUser: class, IUser - { - //b.Property(nameof(AppUser.MyProperty))... - } - } + /* Configure customizations for entities from the modules included */ + + builder.Entity(b => + { + b.ConfigureCustomUserProperties(); + }); + + /* Configure your own tables/entities inside the ConfigureQaDoc method */ + + builder.ConfigureMyProject(); + } + } ``` * 打开 `Visual Studio` 的 `包管理控制台` 选择 `Acme.MyProject.EntityFrameworkCore.DbMigrations` 做为默认项目. 然后编写以下命令为文档模块添加迁移.