diff --git a/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs b/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs index c60f2d682b..befbbb1cdf 100644 --- a/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs +++ b/modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs @@ -22,16 +22,16 @@ namespace VoloDocs.Web.Pages { Projects = (await _projectAppService.GetListAsync()).Items; - if (Projects.Count == 1) - { - return RedirectToPage("./Documents/Project/Index", new - { - projectName = Projects[0].ShortName, - version = DocsAppConsts.Latest, - languageCode = "", - documentName = Projects[0].DefaultDocumentName - }); - } + //if (Projects.Count == 1) + //{ + // return RedirectToPage("./Documents/Project/Index", new + // { + // projectName = Projects[0].ShortName, + // version = DocsAppConsts.Latest, + // languageCode = "", + // documentName = Projects[0].DefaultDocumentName + // }); + //} return Page(); } diff --git a/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs b/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs index d6e615c22e..76b56c8c82 100644 --- a/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs +++ b/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs @@ -51,7 +51,7 @@ namespace Volo.Docs.Documents return await GetDocumentWithDetailsDtoAsync( project, - project.DefaultDocumentName, + project.DefaultDocumentName + "." + project.Format, input.LanguageCode, input.Version ); diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs index 337495f295..4b370c8140 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs @@ -70,6 +70,11 @@ namespace Volo.Docs.Pages.Documents.Project await SetVersionAsync(); await SetLanguageList(); + if (IsDefaultDocument()) + { + return RedirectToDefaultDocument(); + } + if (!CheckLanguage()) { return RedirectToDefaultLanguage(); @@ -83,6 +88,11 @@ namespace Volo.Docs.Pages.Documents.Project return Page(); } + private bool IsDefaultDocument() + { + return DocumentName == Project.DefaultDocumentName; + } + private async Task SetProjectAsync() { Project = await _projectAppService.GetAsync(ProjectName); @@ -114,6 +124,17 @@ namespace Volo.Docs.Pages.Documents.Project }); } + private IActionResult RedirectToDefaultDocument() + { + return RedirectToPage(new + { + projectName = ProjectName, + version = Version, + documentName = "", + languageCode = DefaultLanguageCode + }); + } + private async Task SetProjectsAsync() { var projects = await _projectAppService.GetListAsync(); @@ -228,16 +249,11 @@ namespace Volo.Docs.Pages.Documents.Project private async Task SetDocumentAsync() { - if (DocumentName.IsNullOrWhiteSpace()) - { - DocumentName = Project.DefaultDocumentName; - } - DocumentNameWithExtension = DocumentName + "." + Project.Format; try { - if (DocumentNameWithExtension.IsNullOrWhiteSpace()) + if (DocumentName.IsNullOrWhiteSpace()) { Document = await _documentAppService.GetDefaultAsync( new GetDefaultDocumentInput